WordPress.org

Ready to get started?Download WordPress

Forums

Conditional code and php code (4 posts)

  1. Marcomail
    Member
    Posted 8 years ago #

    I can't see the dynamic content :

    if (is_home()) {

    echo "<div class='sidebartop'>
    <h1><?php _e('Hot Friends'); ?></h1></div>
    <div class='sidebar'>
    <div class='sidebarpadding'>
    .....

    don't work, i can't see all the dynamic text...why ?

  2. Michael_
    Member
    Posted 8 years ago #

    PHP always needs to be embedded in "<?php" and "?>".

    <?php echo 'I am PHP'; ?>
    <h2>I am HTML</h2>
    <?php echo 'I am PHP again'; ?>
    <h2>Some HTML <?php echo '-- and now some PHP'; ?></h2>

  3. Marcomail
    Member
    Posted 8 years ago #

    How can i add to the funcion

    if (is_home()) {

    the other path like category/date ?

    i would like do this:

    if (is_home() and is_date() etc etc

    what i do ?

  4. Michael_
    Member
    Posted 8 years ago #

    Try this:

    <?php if (is_home()) { ?>
    Do stuff
    <?php } elseif(is_search()) { ?>
    Do stuff
    <?php } elseif(is_single()) { ?>
    Do stuff
    <?php } else { ?>
    Everything else
    <?php } // endif ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.