Query Multiple Custom Post Types & Exclude a Taxonomy Term

You should have a look at the arguments of WP_Query. The following arguments should be what you need. Note that tax_query takes an array of arrays. $args = array( ‘post_type’ => array( ‘post’, ‘videos’, ‘music’ ), ‘tax_query’ => array( array( ‘taxonomy’ => ‘content’, ‘field’ => ‘slug’, ‘terms’ => ‘indy’, ‘operator’ => ‘NOT IN’ ) ) … Read more

Order taxonomy terms wordpress

You’re not setting an order anywhere for get_terms, you’re setting it for the query of articles within each term. You need to pass arguments to get_terms if you want an order other than default, which is ASC. $tax = ‘news’; $tax_args = array( ‘order’ => ‘DESC’ ); $tax_terms = get_terms( $tax, $tax_args );

Custom Post taxonomy template

Turned out to be an internal mayashop function in the taxonomy.php page that checks for two particular taxonomies if found populates their pages it not returns to the index.php added my condition & all is well now, Thanks <?php /** * @package WordPress * @subpackage Impero * @since Impero 1.0 */ if ( yiw_is_portfolio_tax( get_query_var(‘taxonomy’) … Read more

Get posts in a subcategory of a chosen parent

You should use get_posts or (even better) custom WP_Query to query posts. You can use get_pages to do this, but get_pages can’t use category (or other taxonomies – just check it in WP sources) to filter results. So your function should look like this: function getPostsInCategory($category) { return get_posts(array( ‘post_status’ => ‘publish’, ‘category’ => $category, … Read more

Counting posts by certain author with custom taxonomy

$args = array( ‘taxonomy’ => ‘special’, ‘posts_per_page’ => -1, ‘author’ => 2 ); $author_category_posts = new WP_Query($args); $count_of_posts_by_author = $author_category_posts->post_count; You can fetch the number of posts made by that author in specific taxonomy.

How to get the get the select values created by ACF plugin in wordpress

In this bit of code: $field = get_field_object(‘field_51d3f9c3f5554’); $field[‘choices’] will contain an array of the available choices for that field, not the currently selected value, $field[‘value’] contains the currently selected value. However, using get_field_object when all you want is the currently selected value is unnecessary. for the correct use of get_field(), read the documentation carefully … Read more

Filter unique custom field value based on custom taxonomy category or other custom field

The filtering can be done with this function totally untested function filter_custom_fields($key=”, $terms=””, $tax=”, $selkey=”, $selval=””) { global $wpdb; $include=””; if ( $selkey && $selval && ( is_string($selval) || is_array($selval) ) ) { $include = ” AND post_id IN (” . $wpdb->prepare(“SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value “, $selkey ); … Read more

Custom Post Types – Taxonomy and Customization

You need to add a taxonomies argument to your registration array: ‘taxonomies’ => array(‘category’) That is: array( ‘labels’ => array( ‘name’ => __( ‘Products’ ), ‘singular_name’ => __( ‘Product’ ), ‘add_new_item’ => __(‘Add New Product’), ‘edit_item’ => __(‘Edit Product’), ‘search_items’ => __(‘Search Products’) ), ‘public’ => true, ‘has_archive’ => true, ‘rewrite’ => array(‘slug’ => ‘products’), … Read more