Show Posts to Author Only

In your Loop, whether for a ‘single’ page or an ‘index’ page, check the post author against the current user ID, and only display the post if they match. Assuming you are using a typical WordPress Loop, something like… global $current_user; get_currentuserinfo(); // start of the Loop if ( have_posts() ) { while ( have_posts() … Read more

get_pagination not working on a custom post type query (using WP_Query)

Pagination is only built “well” in non-custom post-types. Below, I’ll post an article with more detail about the more complex setup required for custom post-type pagination via the WP_Query() method. But to give the direct answer to your question, it’s not working because get_pagination() is not a method that belongs to the WP_Query() object, rather … Read more

Display custom posts randomly in custom taxonomy archive

I’ve finally found the solution thanks to a friend of mine: exploiting get_queried_object() we can set the object name in the script as follows: <?php $obj=$wp_query->get_queried_object(); $args=array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘areas’, ‘field’ => ‘slug’, ‘terms’ => $obj->name ) ), ‘orderby’ => ‘rand’ ); query_posts($args); ?> Hope this can help. Enjoy! 🙂

Displaying tags associated with posts in Custom Post Type

You want to look into the_terms or its big brother get_the_terms. It’s how you display custom taxonomies on the front end — similar to the_category or the_tags. Example: <?php // somewhere in a template file, inside the loop the_terms( $post->ID, // object ID ‘camps_tag’, // your custom taxonomy ‘<p><strong>Tags: </strong></p>’, // before the list ‘, … Read more

populate array with posts

After getting the posts you can easily put them in another array & then return that array function get_sponsors() { $args = array( ‘numberposts’ => -1, ‘post_type’ => ‘movies’ ); $my_movies = get_posts($args); $options = array(); foreach($my_movies as $m) $options[$m->ID] = array( ‘label’ => $m->post_title, ‘value’ => $m->ID ); return $options; }

How To Get Custom Post Type Category Title

From what I understand, you just need to use this in your template as it sounds like you will be using an archive page for a given CPT. <h1><?php post_type_archive_title(); ?></h1> I’ve not been able to test this but you can find more info about the options on this WordPress Codex page. http://codex.wordpress.org/Function_Reference/post_type_archive_title There are … Read more