WordPress.org

Support

Support » Themes and Templates » [Resolved] if is in a category show this else dysplay other

[Resolved] if is in a category show this else dysplay other

  • I have a problem with this loop. I think it’s not closed on the line number 13
    one of you knows how to close it properly?

    <?php if ( in_category('CATEGORY NAME') ) {
    echo"HTML CODE";{ ?>
    <?php if (get_post_meta($post->ID, 'KEY', true) ) { ?>
    
    <!-- html code -->
    
    <?php } else { ?>
    
    <!-- html code -->
    
    <?php }     
    
    elseif ( in_category('CATEGORY NAME 2') ) {
    
    } else {
    
    }
    ?>
Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Andrew Nevins

    @anevins

    Forum moderator

    What is the error you’re getting and which line is it referring to?

    I believe this is it –

    <?php if ( in_category(‘CATEGORY NAME’) ) {
    echo”HTML CODE”;{ <—- notice you are opening another curly bracket, before closing the previous one ?>
    <?php if (get_post_meta($post->ID, ‘KEY’, true) ) { ?>

    Correct variation might be

    <?php if ( in_category('CATEGORY NAME') ) { ?>
    <?php echo"HTML CODE"; ?>
    <?php } elseif (get_post_meta($post->ID, 'KEY', true) ) { ?>
    
    <!-- html code -->
    
    <?php } elseif (some conditional) { ?>
    
    <!-- html code -->
    
    <?php } elseif ( in_category('CATEGORY NAME 2') ) {    
    
    <!-- html code -->
    
    } else {
    <!-- html code -->
    }
    ?>

    on the editor tex code it said line 13 error
    where the code says:
    elseif ( in_category(‘CATEGORY NAME 2’) ) {

    } else {

    }
    ?>

    now i try the loop by Evan Herman

    what is necessary to add in (some conditional)?
    maybe
    (get_post_meta($post->ID, 'KEY', true) )

    sorry
    (get_post_meta($post->ID, ‘KEY’, false) )

    Evan Herman
    thank you very much

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] if is in a category show this else dysplay other’ is closed to new replies.