WordPress.org

Ready to get started?Download WordPress

Forums

Customizr
How to configure page with more article (6 posts)

  1. scapal
    Member
    Posted 5 months ago #

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

    Thank you in advance for your response.

  2. d4z_c0nf
    Member
    Posted 5 months ago #

    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.

  3. scapal
    Member
    Posted 5 months ago #

    Thanks,

    How to bind them to the proper query?

  4. d4z_c0nf
    Member
    Posted 5 months ago #

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

  5. scapal
    Member
    Posted 5 months ago #

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

  6. d4z_c0nf
    Member
    Posted 5 months ago #

    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.

Reply

You must log in to post.

About this Theme

About this Topic

Tags

No tags yet.