Custom Post Type Conditional - Wordpress

I am trying to write a conditional query for a custom message type. I need this to be important for a particular post. So, for example, I have the current code that works for ALL projects:

<?php if ('project' == get_post_type() ) {  ?> 
// Get content 
<?php } ?>

However, I need to specify a specific project with ID 75. Is this possible?

Any help is greatly appreciated.

Greetings

+3
source share
3 answers

you can use the function get_the_ID()inside LOOP:
http://codex.wordpress.org/Function_Reference/get_the_ID

<?php if ('project' == get_post_type() && get_the_ID() == 75) {  ?> 
// Get content 
<?php } ?>
0
source

You can use the global variable $ post for a special custom post.

<?php if($post->post_type == 'project' && $post->ID == '75') : ?> //Get Content <?php endif; ?>

+2
source
if($post->post_type == 'type your post type here' ) : 
  //Get Content

ENDIF;

...

+1
source

All Articles