Support » Theme: Customizr » How to configure page with more article

  • Hello, can i help me make a specifc page with a title, an overview and contains articles.

    Thank you in advance for your response.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You can try adding this to your child theme functions.php:

    add_action('__after_loop', 'my_list_of_posts', 1);
    function my_list_of_posts(){
        if ( ! is_page() )
            return;
    
        $page_query = array(
            //page slug => query args
            'test' => 'category_name=cat-test&posts_per_page=5'
        );
    
        global $post;
        $slug = $post -> post_name;
    
        if ( ! array_key_exists($slug, $page_query) )
            return;
    
        query_posts($page_query[$slug].'&paged='. get_query_var('paged'));
        if( have_posts() && !is_404() ) :
            while ( have_posts() ) :
                the_post();
        ?>
                <article <?php tc__f('__article_selectors') ?>>
                    <?php do_action( '__loop' ); ?>
                </article>
            <?php endwhile; ?>
    
        <?php endif; ##end if have posts ?>
    
        <?php do_action ('__after_loop');##hook of the comments and the posts navigation with priorities 10 and 20 ?>
        <?php
            add_action('__after_article_container', 'wp_reset_query', 1);
    }

    So what you have to do is chose the pages where you want to display articles and bind them to the proper query.

    Thanks,

    How to bind them to the proper query?

    What you want to display, how many posts from what category?

    I will display a page with one or more article below under the layout of the page.

    I told you how to do it. That’s the code.
    You just need to know the page slug and the category from which grab this articles.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to configure page with more article’ is closed to new replies.