WordPress.org

Forums

Page showing posts from one category only (2 posts)

  1. cphx
    Member
    Posted 1 year ago #

    hey,

    I found a lot of such topics, but nothing works for me. What I want is that some pages show posts from only one category.

    It may look like pages with tags or categories, but sidebar must stand where it is, because I need widget there (with widget logic).

    My theme is Twenty Fourteen.

    Thanks in advance,
    cphx

  2. Michael
    Forum Moderator
    Posted 1 year ago #

    for example, in a child theme http://codex.wordpress.org/Child_Themes of Twentyfourteen, create a custom page template http://codex.wordpress.org/Page_Templates, based on page.php;

    replace that section:

    <?php
    				// Start the Loop.
    				while ( have_posts() ) : the_post();
    
    					// Include the page content template.
    					get_template_part( 'content', 'page' );
    
    					// If comments are open or we have at least one comment, load up the comment template.
    					if ( comments_open() || get_comments_number() ) {
    						comments_template();
    					}
    				endwhile;
    			?>

    with a custom query and loop, calling just posts of the special category.

    for some coding ideas, have a look at http://codex.wordpress.org/Page_Templates#A_Page_of_Posts

    http://codex.wordpress.org/Class_Reference/WP_Query
    http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters

Topic Closed

This topic has been closed to new replies.

About this Topic