[Wordpress] conditional script

Discussion in 'WordPress' started by Ruriko, Jan 20, 2009.

  1. #1
    I got the if conditional script working but the problem is the <?php the_title(); ?> & <?php the_category(', ') ?> aren't displaying anyone know why?

    <?php
    $in_subcategory = false;
    foreach( explode( "/", get_category_children( 8 ) ) as $child_category ) {
    if(in_category($child_category))$in_subcategory = true;
    }
    
    if ( $in_subcategory || in_category( 8 ) ) {
    echo '<p class="postmetadata alt">
    						<?php the_title(); ?> is filed under <?php the_category(', ') ?> category. You can visit the <?php the_category(', ') ?> category to find all the episodes of this series.
    
    				
    ';
    } else {
    echo '<span class="bad-cat">Not tasty! Not healthy!</span>';
    }
    ?>
    
    Code (markup):
     
    Ruriko, Jan 20, 2009 IP
  2. MunnaMobile

    MunnaMobile Banned

    Messages:
    234
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    0
    #2
    didn't looked lot in code
    but echo needs semicolan. and the_title() function itself in php script no need of php initiations
    echo '<p class="postmetadata alt">
    						<?php the_title(); ?> is filed under <?php the_category(', ') ?> category. You can visit the <?php the_category(', ') ?> category to find all the episodes of this series.
    
    Code (markup):
     
    MunnaMobile, Jan 20, 2009 IP
  3. Ruriko

    Ruriko Well-Known Member

    Messages:
    4,023
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    130
    #3
    Your suggestion didn't work...
     
    Ruriko, Jan 20, 2009 IP
  4. lvtim

    lvtim Well-Known Member

    Messages:
    291
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    130
    #4
    Are those codes within The Loop? From what I read in the WordPress Codex, i think the_category and the_title should be in The Loop.
     
    lvtim, Jan 21, 2009 IP