Populate metabox dropdown with post title from another Custom Post Type (issues with wp_reset / global $post)

Okay, I’ve got it sorted. I found a post on here with something similar; WordPress wasn’t resetting back into the main loop. So my code is now: /* Show roles metabox */ function show_roles_metabox() { global $post; $tempPost = $post; wp_nonce_field(basename(__FILE__), ‘role_nonce’); $pro_areas = array( ‘One’, ‘Two’, ‘Three’ ); $args = array( ‘post_type’ => ‘proarea’, … Read more

Work and Display a Custom Post Type as a normal Post

Ok, so I think you could apply the codex example as is: function search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { if ($query->is_search) { $query->set(‘post_type’, array( ‘post’, ‘actualizacion’, ‘notificacion’ ) ); } } } add_action(‘pre_get_posts’,’search_filter’); I think you were just missing the !is_admin() check in there… Hope this helps!

Missing Custom Post Type Metadata

The template code is checking to see if the post type is post, and only displaying the post meta information if that is true: if ( ‘post’ === get_post_type() ): ?> Since the custom post type ngobin is being viewed, the above check returns false so the meta data is not displayed. The fix is … Read more

Why get_posts() returns empty array while I am trying to get posts from some specific taxonomies and work properly with others?

After several hours of debugging I have found what caused the problem. Custom taxonomy ‘cadassist_category’ is used for 2 custom post types: product_document and cadassist_file. The posts for taxanomy with ID 653 were of cadassis_file type. And I tried to get posts of product_document type. That is why I got empty array. So if you … Read more

How to sort custom post’s category by id from the theme’s function.php?

You need to change the orderby to ID: $args=array( ‘class’ => ‘select-submit2’, ‘hide_empty’ => false, ‘selected’ => $prop_category_selected, ‘name’ => ‘prop_category’, ‘id’ => ‘prop_category_submit’, ‘orderby’ => ‘ID’, //this changed to ID ‘order’ => ‘ASC’, ‘show_option_none’ => __(‘None’,’wpestate’), ‘taxonomy’ => ‘property_category’, ‘hierarchical’=> true ); wp_dropdown_categories( $args ); ?>

Show posts for current taxonomy

From the above query, it seems that you have passed wrong parameters in tax_query of your query. It should be as follows: ‘tax_query’ => array( array( ‘taxonomy’ => ‘Themes’, //Your custom taxonomy slug ‘field’ => ‘slug’, // this should be field name, not field value ‘terms’ => array(‘environment’), ‘include_children’ => true, ‘operator’ => ‘IN’ ), … Read more