Inspired Media
Member
Posted 1 year ago #
Hi All,
I've got a single post that I want to remove from a specific category on category.php.
Current code is:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<li><a>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<!--/post -->
<?php endwhile; endif; ?>
[Please post code or markup snippets between backticks or use the code button.]
I've searched the net for a few days, but could not find the right answer for this. Anyone who can help me out?
Thanks alot in advance!
Inspired Media
Member
Posted 1 year ago #
Esmi, thanks for linking. I checked that page, but it didn't actually help as it's talking about excluding categories instead of posts.
Not quite. You can use any of the parameters described on http://codex.wordpress.org/Class_Reference/WP_Query in query_posts.
Inspired Media
Member
Posted 1 year ago #
Esmi, since I'm not a php programmer, could you solve the mystery for me?
I know the post has 3 as an id, that's about it...
<?php
if( is_category( 'category-slug') :
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args= array(
''post__not_in' => array( 3 ),
'paged' => $paged
);
query_posts($args);
endif;?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
[...]
Inspired Media
Member
Posted 1 year ago #
Parse error: syntax error, unexpected ':' in is what i'm getting
Typo - missing ). Try:
<?php
if( is_category( 'category-slug') ) :
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args= array(
''post__not_in' => array( 3 ),
'paged' => $paged
);
query_posts($args);
endif;?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
[...]