• wendysahl

    (@wendysahl)


    I have a child theme. I want to exclude all categories except for one on a “posts page” – the front page – is a Static Page that displays a Posts Page called “News.” I’ve read over the Codex regarding the code necessary to exclude categories from the article: Exclude Posts From Some Category.

    I have three questions:

    1. It’s unclear exactly WHICH file I need to change the code in to exclude posts from most categories. Which file or files do I need to add the exclude code to?

    2. The coding is also different than the Twenty Twelve theme files, I assume it’s been updated as it appears in later themes. Is this going to cause a problem and make the whole thing break?

    3. In the example in Exclude Posts From Some Category the example uses categories “3” and “8.” Are those numbers just an example or do I need to figure out the numerical value (or something) assigned to the categories I have words for?

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • esmi

    (@esmi)

    1. Your child theme’s category.php template file.

    2. Pardon?

    3. Those numbers are category ids. Substitute the ids for the categories that you wish to exclude.,

    Thread Starter wendysahl

    (@wendysahl)

    Re: 2. In the Exclude Posts From Some Categories article the code shown in the example reads as this:
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    In the twenty twelve theme category.php file it reads:

    /* Start the Loop */
    			while ( have_posts() ) : the_post();
    
    				/* Include the post format-specific template for the content. If you want to
    				 * this in a child theme then include a file called called content-___.php
    				 * (where ___ is the post format) and that will be used instead.
    				 */
    				get_template_part( 'content', get_post_format() );
    
    			endwhile;
    
    			twentytwelve_content_nav( 'nav-below' );
    			?>

    I’m finding the difference in the wording to be confusing. Thanks 🙂

    esmi

    (@esmi)

    <div id="primary" class="site-content">
    		<div id="content" role="main">
    		<?php if ( have_posts() ) : ?>

    From category.php in the 2012 theme.

    [EDITED}

    Thread Starter wendysahl

    (@wendysahl)

    But I make the changes in the category.php? (child theme category.php that is)

    Thread Starter wendysahl

    (@wendysahl)

    I added a category.php to my child theme. Then I added this bit to exclude these categories from appearing on the front-page “News.” It didn’t work. It didn’t kill everything either which is something.

    get_header(); ?>
    
    	<section id="primary" class="site-content">
    		<div id="content" role="main">
    
    <?php if ( is_home() ) {
    query_posts($query_string . '&cat=-art-design,-ideas-and-thoughts,-life-family,-sketchbook,-super-awesome');
    }
    ?>
    
    	<?php if ( have_posts() ) : ?>

    Thread Starter wendysahl

    (@wendysahl)

    I’ve tried using the code in both a functions.php and category.php files and can’t get it to work. One of the problems is that my categories all have names and not numbers. I’ve looked at the permalinks attached to them, the URLs, and I’ve tried changing the permalink settings under Settings –> Reading to no avail. It’s words all the way. So I attempted to use the words as in the example above and am not able to get it to work.

    If anyone can clarify specifically exactly where the following code belongs in order to exclude categories of posts from the page of posts I would really appreciate it.

    query_posts($query_string . '&cat=-art-design,-ideas-and-thoughts,-life-family,-sketchbook,-super-awesome');
    }
    ?>
Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Exclude Posts From Some Category – Twenty Twelve’ is closed to new replies.