How to write an if statement which reads: ‘if is this custom post type or a child of it do the following’?

I accidentally got the answer: <?php global $post; $the_post_parent = $post->post_parent; $the_post_ID = $post->ID; $cat_posts = get_posts(‘post_type=bbp_forum&posts_per_page=-1’); print_r($post_parent); ?> <?php foreach ( $cat_posts as $post ) : ?> <li <?php if ( $post->ID == $the_post_ID || $post->ID == $the_post_parent ) echo ‘class=”current”‘; ?>> <a href=”https://wordpress.stackexchange.com/questions/13966/<?php the_permalink(); ?>” title=”<?php printf( esc_attr__( ‘Permalink to %s’, ‘twentyten’ ), … Read more

How to pull a number posts from a specific Taxonomy within a Custom Post type

The get_the_terms() returns a list of term objects. So first of all, you need to treat the output as a list rather than a single element. The name you’re looking for is stored in the name field. $artistnames = get_the_terms($post->ID, ‘artist’); if (!empty($artistnames)) : ?> foreach ($artistnames as $obj) { $name = $obj->name; // Do … Read more

Display one post based on ID from $_GET

If you want to reach the “single” page of a custom post type (or even a regular post), you can do this by going to http://example.com?p=[post_id]&post_type=[post_type_name]. If you use Pretty permalinks WordPress will redirect you to the “canonical” link, which may look like http://example.com/my-post-type/my-post-name/. So by changing the target of your form and the post_id … Read more

add a “list” into add meta box : problem

You are missing the declaration of the HTML select tag which options are his children so just add something like this: function myplugin_inner_custom_box() { // Use nonce for verification wp_nonce_field( plugin_basename( __FILE__ ), ‘myplugin_noncename’ ); // The actual fields for data entry echo ‘<label for=”myplugin_new_field”>’; _e(“Description for this field”, ‘myplugin_textdomain’ ); echo ‘</label> ‘; echo … Read more