Target Post Type from array Query

$my_query->post_type refers to the post type of the query (in this case an array), and not the results. (Its recommended to use $my_query->get(‘post_type’) too, but anyway…). To get the current post’s (in the loop) post type: $post_type = get_post_type(); You can also use that function outside the loop by passing the post object / ID. … Read more

Show post type taxonomy

Set the public parameter in register_post_type to true like this: public’ => true, public (boolean) (optional) Controls how the type is visible to authors (show_in_nav_menus, show_ui) and readers (exclude_from_search, publicly_queryable). Default: false ‘true’ – Implies exclude_from_search: false, publicly_queryable, show_in_nav_menus, and show_ui. The built-in types attachment, page, and post are similar to this. And create a … Read more

Querying for multiple post types in SQL

Couple of things to note; one’s a WordPress issue, the other an SQL issue: For WordPress, instead of editing the plugin files directly, you should use the ‘getarchives_where’ filter it provides, and change the query there. For SQL, in order to query for multiple post types, you need a conditional statement in the query, so … Read more

Conditional based on post meta

to add a condition on a meta value, you can modify the test like that : function fq_disable_single_cpt_views() { $queried_post_type = get_query_var(‘post_type’); $cpts_without_single_views = array( ‘ait-item’ ); $_ait_item_item_featured = get_post_meta(get_the_ID(), “_ait-item_item-featured”, TRUE); if ( is_single() && in_array( $queried_post_type, $cpts_without_single_views ) && (“0” === $_ait_item_item_featured) ) { wp_redirect( home_url( ‘/sorry’ ), 301 ); exit; } }

How to edit default post settings

Refer to the manage_posts_columns filter, and also the manage_posts_custom_column action. Here is a really old tutorial, linked from the Codex, that might be instructive. (Caveat: it’s from 2007; some things might be out of date.) Edit The above hooks are for the manage posts screen. To remove/add meta boxes to the edit post screen, see … Read more