Title: php conditional statement problem, wordpress issue?
Last modified: August 18, 2016

---

# php conditional statement problem, wordpress issue?

 *  [axiomjunglist](https://wordpress.org/support/users/axiomjunglist/)
 * (@axiomjunglist)
 * [19 years ago](https://wordpress.org/support/topic/php-conditional-statement-problem-wordpress-issue/)
 * I have a real issue right now with a conditional statement that I’m trying to
   get working. Maybe someone out there has solved it somehow or knows more php 
   than I do.
 * Here is the link to the php code I’m using: [http://latestpost.pastebin.co.uk/3890](http://latestpost.pastebin.co.uk/3890)
 * What the above code does is pull the latest three posts from a specified catagory
   into the sidebar. That’s great, but I want to go a step further. I want to have
   the code only execute on a specific page, and not others.
 * I’ve tried using the ‘is_page’ conditional statement, but I can’t seem to code
   it right. I’ve put it after the ‘in_catagory’ using && and no dice. Also tried
   a double if statement…with no success. I don’t even get an error. It just doesn’t
   work.
 * Is is possible to do or am I just spinning gears?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [bpartch](https://wordpress.org/support/users/bpartch/)
 * (@bpartch)
 * [19 years ago](https://wordpress.org/support/topic/php-conditional-statement-problem-wordpress-issue/#post-568316)
 * Hello
 * If I understand you only want this code to execute on a specific page? If this
   is correct you just need to surround it with an ( if is_page(id) ) like below.
 *     ```
       <?php if ( is_page(page id number or name) ) { ?>
       <h2>Journal</h2><ul><?php query_posts('cat=4&showposts=3'); ?>
       <?php while (have_posts()) : the_post(); ?>
       <?php if ( in_category(4) ) { ?>
       <li><a href=<?php the_permalink(); ?>><?php the_title(); ?></a></li>
       <?php } else {
       }; ?>
       <?php endwhile; ?>
       </ul>
       <?php } ?>
       ```
   
 * If I have misunderstood or you have more questions just ask. 🙂
 *  Thread Starter [axiomjunglist](https://wordpress.org/support/users/axiomjunglist/)
 * (@axiomjunglist)
 * [19 years ago](https://wordpress.org/support/topic/php-conditional-statement-problem-wordpress-issue/#post-568324)
 * You sir, are a god among men…thank you!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘php conditional statement problem, wordpress issue?’ is closed to new
replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [axiomjunglist](https://wordpress.org/support/users/axiomjunglist/)
 * Last activity: [19 years ago](https://wordpress.org/support/topic/php-conditional-statement-problem-wordpress-issue/#post-568324)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
