Is It Possible To Add Custom Post Type Menu As Another Custom Post Type Sub Menu

Yes. When you register your post type you need to set show_in_menu to the page you would like it displayed on. Adding a custom post type as a sub-menu of Posts Here we set the “movies” post type to be included in the sub-menu under Posts. register_post_type( ‘movies’, array( ‘labels’ => array( ‘name’ => __( … Read more

Include custom taxonomy term in search

I would recommend the Search Everything plugin too, but if you want to implement this using WP’s search function, here’s the code I’m using in my Atom theme: // search all taxonomies, based on: http://projects.jesseheap.com/all-projects/wordpress-plugin-tag-search-in-wordpress-23 function atom_search_where($where){ global $wpdb; if (is_search()) $where .= “OR (t.name LIKE ‘%”.get_search_query().”%’ AND {$wpdb->posts}.post_status=”publish”)”; return $where; } function atom_search_join($join){ global … Read more

Add category base to url in custom post type/taxonomy

Change your rewrite to add the course query var: ‘rewrite’ => array(‘slug’ => ‘courses/%course%’) Then filter post_type_link to insert the selected course into the permalink: function wpa_course_post_link( $post_link, $id = 0 ){ $post = get_post($id); if ( is_object( $post ) ){ $terms = wp_get_object_terms( $post->ID, ‘course’ ); if( $terms ){ return str_replace( ‘%course%’ , $terms[0]->slug … Read more

Custom Post Type URL Rewriting?

When you register the custom post type, you have to specify that the rewrite rule shouldn’t be prepended with the existing URL structure. In short, this means that this line in your register_post_type call: ‘rewrite’ => array(‘slug’ => ‘projects’), should turn into this: ‘rewrite’ => array(‘slug’ => ‘projects’,’with_front’ => false), For more info, check out … Read more

How to Add Tags to Custom Post Type?

Like this: (Where it says “portfolio” is where you register the taxonomy to a post type add_action( ‘init’, ‘create_tag_taxonomies’, 0 ); //create two taxonomies, genres and tags for the post type “tag” function create_tag_taxonomies() { // Add new taxonomy, NOT hierarchical (like tags) $labels = array( ‘name’ => _x( ‘Tags’, ‘taxonomy general name’ ), ‘singular_name’ … Read more

Pagination not working with custom loop

I’ve run into this problem with PageNavi before. My solution is to hijack the $wp_query variable temporarily and then reassign it after closing the loop. An exmaple: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args=array( ‘post_type’=>’post’, ‘cat’ => 6, ‘posts_per_page’ => 5, ‘paged’=>$paged ); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query($args); /* … Read more

How do I query a custom post type with a custom taxonomy?

Firs of all don’t use query_posts() ever, read more about it here: When should you use WP_Query vs query_posts() vs get_posts()?. You have to use WP_Query to fetch posts what you need. Read documentation for it. In your case the query could be like this: $the_query = new WP_Query( array( ‘post_type’ => ‘Adverts’, ‘tax_query’ => … Read more

Extending the search context in the admin list post screen

I solved filtering the query by adding the join on the postmeta table and changing the where clause. tips on filtering the WHERE clause (often require regular expression search&replace) are here on codex: add_filter( ‘posts_join’, ‘segnalazioni_search_join’ ); function segnalazioni_search_join ( $join ) { global $pagenow, $wpdb; // I want the filter only when performing a … Read more