Title: Combining Conditional Tag/PHP problem
Last modified: August 18, 2016

---

# Combining Conditional Tag/PHP problem

 *  Resolved [altexasgirl](https://wordpress.org/support/users/altexasgirl/)
 * (@altexasgirl)
 * [20 years ago](https://wordpress.org/support/topic/combining-conditional-tagphp-problem/)
 * 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)

 *  [peiqinglong](https://wordpress.org/support/users/peiqinglong/)
 * (@peiqinglong)
 * [20 years ago](https://wordpress.org/support/topic/combining-conditional-tagphp-problem/#post-397580)
 * 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](https://wordpress.org/support/users/altexasgirl/)
 * (@altexasgirl)
 * [20 years ago](https://wordpress.org/support/topic/combining-conditional-tagphp-problem/#post-397582)
 * 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/](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!
 *  [peiqinglong](https://wordpress.org/support/users/peiqinglong/)
 * (@peiqinglong)
 * [20 years ago](https://wordpress.org/support/topic/combining-conditional-tagphp-problem/#post-397590)
 * 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](https://wordpress.org/support/users/altexasgirl/)
 * (@altexasgirl)
 * [20 years ago](https://wordpress.org/support/topic/combining-conditional-tagphp-problem/#post-397633)
 * 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!
 *  [peiqinglong](https://wordpress.org/support/users/peiqinglong/)
 * (@peiqinglong)
 * [20 years ago](https://wordpress.org/support/topic/combining-conditional-tagphp-problem/#post-397696)
 * 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](https://wordpress.org/support/users/altexasgirl/)
 * (@altexasgirl)
 * [20 years ago](https://wordpress.org/support/topic/combining-conditional-tagphp-problem/#post-397717)
 * Not a problem – I appreciate all your help. The DIV works fine now. Thanks so
   much and God bless!
 *  [Samuel B](https://wordpress.org/support/users/samboll/)
 * (@samboll)
 * [20 years ago](https://wordpress.org/support/topic/combining-conditional-tagphp-problem/#post-397719)
 * Hi ALTexasGirl,
    I really like your theme. Is it yours?
 *  Thread Starter [altexasgirl](https://wordpress.org/support/users/altexasgirl/)
 * (@altexasgirl)
 * [20 years ago](https://wordpress.org/support/topic/combining-conditional-tagphp-problem/#post-397724)
 * Thanks! It is mine – a custom design from EWebscapes – [http://elegantwebscapes.com/](http://elegantwebscapes.com/)
 *  [peiqinglong](https://wordpress.org/support/users/peiqinglong/)
 * (@peiqinglong)
 * [20 years ago](https://wordpress.org/support/topic/combining-conditional-tagphp-problem/#post-397737)
 * 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.

## Tags

 * [conditional](https://wordpress.org/support/topic-tag/conditional/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [tag](https://wordpress.org/support/topic-tag/tag/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 9 replies
 * 3 participants
 * Last reply from: [peiqinglong](https://wordpress.org/support/users/peiqinglong/)
 * Last activity: [20 years ago](https://wordpress.org/support/topic/combining-conditional-tagphp-problem/#post-397737)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
