Custom WP_Query doesn’t display all posts

All thanks to @PieterGoosen’s comment, I figured out that this issue was due to a setting within the WPML (multilingual) plugin. Under the ‘translation management’->’multilingual content setup’ tab of the plugin settings, there is a section for ‘custom posts’. In this section, my ‘publications’ post type was not set for translation, and this somehow prevented … Read more

ACF repeater field usage

Simply use get_sub_field(“session_speaker”); function to retrieve that data. As you’ve said this is a relational field, it will return an array of post objects according to the docs. In order to get data from each speaker, you need to loop through the resulting array. Example: $speakers = get_sub_field(“session_speaker”); if ($speakers && count($speakers)>0) { foreach ($speakers … Read more

Showing only one category on portfolio page BUT filtering remaining categories with Isotope

You can just get the terms from the current query. To achieve this you can use wp_get_object_terms(), but it expects IDs, which we can extract by using wp_list_pluck() on the query objects posts property. It seems like you only need the names, which we can extract again with wp_list_pluck() from the result wp_get_object_terms() returns. Last … Read more

Conditional Tags for specific category of custom posts

Try using has_term() which accepts a term_name, term_id, or slug to test again. You’ll need to pass the post_id too, something like this: global $post; if( isset( $post ) && is_singular( ‘my_custom_post_type’ ) && has_term( ‘my_custom_post_type_category’, ‘my_custom_taxonomy’, $post->ID ) ) { // Code Goes Here… } You may also be able to use has_category() which … Read more

Creating custom post type with custom taxonomy and custom fields programatically

Create Custom Post Type function create_product() { $labels = array( ‘name’ => _x( ‘Product’, ‘post type general name’, ‘stacy’ ), ‘singular_name’ => _x( ‘product’, ‘post type singular name’, ‘stacy’ ), ‘menu_name’ => _x( ‘Products’, ‘admin menu’, ‘stacy’ ), ‘name_admin_bar’ => _x( ‘Product’, ‘add new on admin bar’, ‘stacy’ ), ‘add_new’ => _x( ‘Add New’, ‘product’, … Read more

How to add and clear custom post types and taxonomies in a plugin? Considerations for existing data

Custom post types and taxonomies can be registered using register_post_type() and register_taxonomy(). These functions do not actually create any data in the database. Data is added when users populate content (posts and taxonomies). When a plugin is disabled, any post types and taxonomies that it registers will be unregistered, but all of their data in … Read more

Query Custom Post Types with checkboxes

You aren’t constructing the meta_query correctly. It is close but not quite right. $searchArray = array(); $searchArray = array(‘relation’ => ‘OR’,); // here is the change // loop over checked checkboxes if(!empty($_POST[‘course_location’])) { foreach($_POST[‘course_location’] as $check) { // echo ‘<h1>’.$check.'</h1>’; $searchArray[] = array(‘key’ => ‘course_location’,’value’ => $check,’compare’ => ‘LIKE’,); } } As you have it … Read more