Site logo

[Resolved] Create custom page with top posts

Home Forums Support [Resolved] Create custom page with top posts

Home Forums Support Create custom page with top posts

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1066819
    Angelica

    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

    #1066931
    Tom
    Lead Developer
    Lead Developer

    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 🙂

    #1066989
    Angelica

    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();
    	}
    }
    #1067622
    Tom
    Lead Developer
    Lead Developer

    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.

    #1067652
    Angelica

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

    It’s an amazing plugin, Tom.

    #1067891
    Tom
    Lead Developer
    Lead Developer

    Glad you like it! 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.