Support » Fixing WordPress » IFELSE problem – I am php incompetent

  • Hi All, – thanks for help up to date.
    I am using the Sticky Plugin to include a feature post/Page. It is working. I am experimenting with a a conditional feature on certain categories and that works, but I cannot get the conditionality to work for a Page or Category – Im sure its the way Im writing the code. Or it may be the way the Plugins pointers work checking the post and category.
    But if someone can assist in cleaning up the basic code I would be grateful.

    Basically – I have 2 “checks that are in their own statement – Im sure they can be checked together.
    What is happening is the first check operates – ie if is_category but the second feature box does not work – ie it doesnt diplay the post on a specified Page – which it should.
    I wouyld preffer that both checks are done at the same time .

    <div id=”bx”>
    <?php get_a_post(53); ?>
    <h3><?php the_title(); ?></h3>
    <?php the_content(); ?>
    <?php if(is_category(’12’) || is_category(‘5’) || is_category(‘8′) || is_category(’27’) || is_category(‘7’) ) : ?>
    <h2>Featured Post</h2>
    <?php get_a_post(57); ?>
    <h3><?php the_title(); ?></h3>
    <?php the_content(); ?>
    <?php endif; ?>
    </div>

    <div id=”bx”>
    <?php if(is_page(‘6’) ) : ?>
    <h2>Featured Post</h2>
    <?php get_a_post(57); ?>
    <h3><?php the_title(); ?></h3>
    <?php the_content(); ?>
    <?php endif; ?>
    </div>

    Please excuse my code – I am not up to speed in php.
    Anybody – any assistance is welcome.
    Thanks – keep well.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Murry, in which theme template are you placing the second if statement (for the Page)? If your theme includes a page.php, make sure to add it there. If not, it should reside in index.php.

    Hi kafkaesqui,
    Sorry – should have explained. Using a Mod of Kubrick (3 column).
    The two pieces of code follow each other as written in the sidebar (or did in my test model). I use the same sidebar in Page and Cat templates.
    I have reverted to using to display on all areas of the site for now :
    <div id=”bx”>
    <?php get_a_post(57); ?>
    <h3><?php the_title(); ?></h3>
    <?php the_content(); ?>
    </div>
    But I am trying to display only in certain cats and or pages.
    The original code example was meant to do that – it didnt.
    Suggestions?

    I’ve modded your code by including is_page() in your first if statement. But it shouldn’t be any different in real functionality. However, you can try it to see if it works for you (working fine here):

    http://paste.uni.cc/7225

    Thanks kafkaesqui,
    This works for me. There are a couple of small quirks – like on one Page – the whole of the include page shows whereas on others it cuts with a “more” – anyway – I see what you have done – I will do some fiddling now.
    Thanks – the help was great.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘IFELSE problem – I am php incompetent’ is closed to new replies.