You want to edit the single.php or the sidebar.php depending on where these links are located.
create a section that query’s the cat:
<div id=”show-links”>
<!–php magic–>
</div>
Is_category
`
<?php
if ( is_category(‘1’) { ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<p><?php the_title(); ?></p>
<?php endwhile; endif; ?>
<?php }
else if( is_category(‘2’)){ ?>
<!–Have Fun–>
<?php } ?>
You want to edit the single.php or the sidebar.php depending on where these links are located.
create a section that query’s the cat:
<div id=”show-links”>
<!–php magic–>
</div>
Is_category
<?php
if ( is_category('1') { ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<p><?php the_title(); ?></p>
<?php endwhile; endif; ?>
<?php }
else if( is_category('2')){ ?>
<!--Have Fun-->
<?php } ?>
Not sure if that’s exactly right but puts you in the right direction
Yeah, that’s what I tried… I edited the single.php but it didn’t work. I didn’t even try to do it with three different ifs (which I would need) because two already turned out impossible and didn’t show anything but fatal errors and script time outs 🙁
I had to do that with is_page for a website give it a try, should work just fine
Won’t work:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div id="single-reviewpost">
<?php if ( is_category('&cat=348, 347, 353, 408, 296, 215') ) { ?>
<?php get_template_part( 'loop-single', 'single' ); ?>
<?php get_sidebar( 'review' ); ?>
</div><div id="single-newspost">
<?php } else if ( is_category('&cat=540') ) { ?>
<?php get_template_part( 'loop-single', 'single' ); ?>
</div><div id="single-blogpost">
<?php } else if ( is_category('&cat=-540, -348, -347, -353, -408, -296, -215') ) { ?>
<?php get_template_part( 'loop-single', 'single' ); ?>
<?php get_sidebar( 'blog' ); ?>
</div><?php } ?>
<?php endwhile; endif; ?>
Won’t work either:
<div id="single-reviewpost">
<?php if ( is_category('&cat=348, 347, 353, 408, 296, 215') ) { ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part( 'loop-single', 'single' ); ?>
<?php get_sidebar( 'review' ); ?>
<?php endwhile; endif; ?>
</div><div id="single-newspost">
<?php } else if ( is_category('&cat=540') ) { ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part( 'loop-single', 'single' ); ?>
<?php endwhile; endif; ?>
</div><div id="single-blogpost">
<?php } else if ( is_category('&cat=-540, -348, -347, -353, -408, -296, -215') ) { ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part( 'loop-single', 'single' ); ?>
<?php get_sidebar( 'blog' ); ?>
<?php endwhile; endif; ?>
</div><?php } endif; ?>
Both won’t show any errors but will simply display nothing…
Most likely what I tried isn’t even possbile but I don’t have a clue…
Oh, I got it 😀
This seems to work just fine:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div id="single-reviewpost">
<?php if ( query_posts($query_string . '&cat=348, 347, 353, 408, 296, 215') ) { ?>
<?php get_template_part( 'loop-single', 'single' ); ?>
<?php get_sidebar( 'review' ); ?>
</div><div id="single-newspost">
<?php } else if ( query_posts($query_string . '&cat=540') ) { ?>
<?php get_template_part( 'loop-single', 'single' ); ?>
</div><div id="single-blogpost">
<?php } else if ( query_posts($query_string . '&cat=-540, -348, -347, -353, -408, -296, -215') ) { ?>
<?php get_template_part( 'loop-single', 'single' ); ?>
<?php get_sidebar( 'blog' ); ?>
</div><?php } ?>
<?php endwhile; endif; ?>
I’m sure there are more elegant ways to do this but I’m happy that I got it to work out at all so for now I’m happy with this 😀
LOL yeah its not always pretty but sometimes those ugly hacks are needed to get projects finish. i say get it out first then prioritize making it better
That may be a bit cleaner, you only need to exit the php to execute the html
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div id="single-reviewpost">
<?php if ( query_posts($query_string . '&cat=348, 347, 353, 408, 296, 215') ) {
get_template_part( 'loop-single', 'single' );
get_sidebar( 'review' ); ?>
</div><div id="single-newspost">
<?php } else if ( query_posts($query_string . '&cat=540') ) {
get_template_part( 'loop-single', 'single' ); ?>
</div><div id="single-blogpost">
<?php } else if ( query_posts($query_string . '&cat=-540, -348, -347, -353, -408, -296, -215') ) {
get_template_part( 'loop-single', 'single' );
get_sidebar( 'blog' ); ?>
</div><?php }endwhile; endif; ?>