Forums

[resolved] Combining Conditional Tag/PHP problem (10 posts)

  1. ALTexasGirl
    Member
    Posted 3 years ago #

    I currently have the list of my four recent posts displayed inside my post, but I only want to show it on the post (single) page. I tried adding a conditional single tag, but I keep getting a parse error. How can I combine the two php tags:

    Here is the code I want displayed:


    <center><b>Latest News:<i>
    <?php get_archives('postbypost',"4",1,"","",""); ?></b></center></i>

    I tried this and I got a parse error:


    <?php
    if (is_single()) { echo '
    <center><b>Latest News:<i>
    <?php get_archives('postbypost',"4",1,"","",""); ?></b></center></i>
    ';} ?>

    Thanks!

  2. peiqinglong
    Member
    Posted 3 years ago #

    Try something like this:

    <?php if (is_single())
    {
    echo "<center><s t r o n g><e m>Latest News:";
    print get_archives('postbypost',"4",1,"","","");
    echo "</e m></s t r o n g></center>";
    } ?>

    Removing the spaces in the strong and em tags of course.

  3. ALTexasGirl
    Member
    Posted 3 years ago #

    Thanks! That took care of the parse error, but it does not have any line breaks. How can I add that in?

    You can see what I mean here - http://www.onthebaseline.com/2006/06/01/justine-henin-hardenne-scores-birthday-win-at-roland-garros/

    I tried it out with IE, Firefox, and Safari

    Thanks so much!

  4. peiqinglong
    Member
    Posted 3 years ago #

    What I would do is style it with CSS. So something like this:

    In you CSS file:

    #latestnews {margin: 2px 0; padding: 0; }
    #latestnews h2 {font: 10px bold italic; text-align: center; }

    Then change the code to:

    <?php if (is_single())
    {
    echo "<div id="latestnews"><h2>Latest News:</h2>< p >";
    print get_archives('postbypost',"4",1,"","","");
    echo "< /p ></div>";
    } ?>

    That should do the trick...you may have to alter the CSS code depending on what you want.

  5. ALTexasGirl
    Member
    Posted 3 years ago #

    I tried the div code, but I kept getting an parse error. I did remove the spaces between the < p > codes .

    Right now, I've got it customized using < br / > codes, but I'd like to have the functionability of the div. Any ideas on what I'm doing wrong?

    Thanks a ton!

  6. peiqinglong
    Member
    Posted 3 years ago #

    Oh I'm sorry, I made a mistake. Try this:

    <?php if (is_single())
    {
    echo "<div id='latestnews'><h2>Latest News:</h2>< p >";
    print get_archives('postbypost',"4",1,"","","");
    echo "< /p ></div>";
    } ?>

    Can't have double double quotes.

  7. ALTexasGirl
    Member
    Posted 3 years ago #

    Not a problem - I appreciate all your help. The DIV works fine now. Thanks so much and God bless!

  8. samboll
    moderator
    Posted 3 years ago #

    Hi ALTexasGirl,
    I really like your theme. Is it yours?

  9. ALTexasGirl
    Member
    Posted 3 years ago #

    Thanks! It is mine - a custom design from EWebscapes - http://elegantwebscapes.com/

  10. peiqinglong
    Member
    Posted 3 years ago #

    Not a problem, glad to be of assistance =)

Topic Closed

This topic has been closed to new replies.

About this Topic