• Resolved altexasgirl

    (@altexasgirl)


    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!

Viewing 9 replies - 1 through 9 (of 9 total)
  • 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.

    Thread Starter altexasgirl

    (@altexasgirl)

    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 – https://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!

    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.

    Thread Starter altexasgirl

    (@altexasgirl)

    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!

    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.

    Thread Starter altexasgirl

    (@altexasgirl)

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

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

    Thread Starter altexasgirl

    (@altexasgirl)

    Thanks! It is mine – a custom design from EWebscapes – https://elegantwebscapes.com/

    Not a problem, glad to be of assistance =)

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Combining Conditional Tag/PHP problem’ is closed to new replies.