Site logo

Archived topic

Create custom page with top posts

5 replies · Started by Angelica on November 18, 2019

Viewing posts 1–6 of 6

I am trying to create a page with top posts but so far all I managed was to create a template and copy the contents of the archive page. Nothing works.

I can handle the query code (gonna use wordpress popular posts query), but no clue as to how to do it using GP.

What I want to achieve: https://anthemes.com/themes/food/popular/
What I have: https://doce.blog.br/top

Hi there,

How are you setting the query right now? In a custom page template? If so, you should just be able to set your necessary options in your WP_Query call.

Let me know :)

I managed to get the query going, the title and description are all set.

But I still get no pagination, no images and no layout like the main blog (I'm using 3 columns).

https://doce.blog.br/top

Home: https://doce.blog.br/

I only copied the index.php template and added:
$query = new WP_Query( 'post_type=post&meta_key=views_weekly&orderby=meta_value_num&order=DESC');

And I have some filters to get my title and custom description for the page:

add_filter( 'get_the_archive_title', function( $title) {
    if ( is_page( 'top' ) ) {
        $title = get_the_title();
    }
    return $title;
}, 50 );

add_action( 'generate_after_archive_title', 'teste' );
function teste(){
	if ( is_page( 'top' ) ) {
	$desc = '<div class="taxonomy-description">ssss%s</div>';
	echo get_the_content();
	}
}

It looks like you're using WP Show Posts now, which is a really good idea. Otherwise, you'll need to add those elements (pagination, featured images, columns) into your page template.

Yes, it works great, I wish it inherited the layout options as well.

It's an amazing plugin, Tom.

Glad you like it! :)

This archived topic is closed to new replies.