Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author scribu

    (@scribu)

    If you want to exclude categories, exclude them from the initial archive page:

    If a user goes to http://yoursite.com/category/parent/ and you make it so that he doesn’t see posts in the child-excluded category, for example, he won’t see them when using the links generated by Smarter Navigation either.

    Here’s how you can do that:

    http://wordpress.stackexchange.com/questions/21341/alternative-to-query-posts-for-main-loop

    Thread Starter Design Dude

    (@dandan-wongcom)

    Hmmm, I think that there might be a misunderstanding, or else I don’t understand WP/php well enough to execute your answer above.
    Here’s what I’m trying to do:

    next_post_smart('%link', '<', TRUE, '4');
    previous_post_smart('%link', '>', TRUE, '4');

    So I want Smarter Navigation to navigate through posts of a referrer category, but I want to exclude any posts from the post ID ‘4’ category.

    Plugin Author scribu

    (@scribu)

    No, I understood what you’re trying to achieve and the way to do it is through WP_Query, since that’s what the Smarter Navigation plugin looks at.

    You do have to understand WordPress fairly well to do it, though. Maybe this presentation will help:

    Thread Starter Design Dude

    (@dandan-wongcom)

    I’ll take a look thanks. After thinking more about what you said it sunk in.
    Now, I just need to figure out how to use queries.

    Thread Starter Design Dude

    (@dandan-wongcom)

    Shouldn’t this work using below? I tried and it did not…
    <?php query_posts($query_string . ‘&cat=-4’); ?>

    Plugin Author scribu

    (@scribu)

    No, because SN collects the query vars before the template is loaded. It has to because cookies can’t be set once any output is sent to the browser.

    Thread Starter Design Dude

    (@dandan-wongcom)

    Got it working! Thanks. So simple once I got my head around it.

    hello @scribu, as you described above, I created a WP_query inside my taxonomy-arquivos.php template with include_children set to false:

    $args = array(
    		'orderby' => ($term->parent) ? 'date' : 'rand',
    		'post_status' => 'publish',
    		'tax_query' => array(
    			array(
    				'taxonomy' => 'arquivos',
    				'field' => 'slug',
    				'terms' => get_query_var( 'term' ),
    				'include_children' => false
    			)
    		)
    	);
    
    	$the_query = new WP_Query( $args );
    
    	while( $the_query->have_posts() ) {
    
    		$the_query->the_post();

    But when I click on a post and navigate, I still get some posts of a children taxonomy.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: Smarter Navigation] Trying to exclude categories… using CPT’ is closed to new replies.