How to add terms to my tax_query based off of the current post
‘terms’ => array(‘$tags1’), Remove the single quotes and it should look like ‘terms’ => array($tags1) OR ‘terms’ => $tags1 No need to make it an array, if you are using just one value.
‘terms’ => array(‘$tags1’), Remove the single quotes and it should look like ‘terms’ => array($tags1) OR ‘terms’ => $tags1 No need to make it an array, if you are using just one value.
The NOT IN and != comparison operators work fine, however be aware that if you are using meta then your data may not be working in the way you expect. Specifically, meta_keys don’t have to be unique per post. A post can have _no_interest set to 1 AND have another meta row with it set … Read more
It is necessary to execute that function if you want to use the template functions such as the_title() & the_permalink(). You should not use it if you aren’t using those kind of functions but for the themes it’s generally recommended to use these functions since they automatically ensure that all wordpress filters are being applied. … Read more
The way you have built that query it is possible for you to have a bunch of empty values. For example, if grad is not present then you end up searching ex_lokacija keys for empty strings. Since your main relation is AND all of the terms have to ‘hit’ so it seems likely to me … Read more
I’m slightly surprised that the first would work, because it’s terms, not term. Anyway, the correct way to do this is: $args = array( ‘post_type’ => array(‘product’, ‘comic’, ‘magazine’), ‘tax_query’ => array( array( ‘taxonomy’ => ‘Genres’, ‘terms’ => array( ‘hot’, ‘home’ ), ), ‘posts_per_page’ => 10 );
I believe Milo is right, it’s probably a filter affecting this. Ajax requests look like admin requests (that is, is_admin() returns true), so it’s possible that something is checking if is_admin() and adding the filter in those cases. You can set ‘suppress_filters’ => true in your args array and it will probably work. Note that … Read more
Where/how are you defining $category_id? Reference the Codex entry for WP_Query() category parameters. WP_Query() expects category IDs to be passed as integers, not as strings: If $category_id is an integer, pass it to ‘cat’. If $category_id is an array (of category IDs, again as integers), pass it to ‘category__in’
For scripts this is no-brainer – just enqueue inside my_gallery() function and they will be output in footer (since header already passed). However stylesheets are a challenge, they are only supposed to work in head section and enqueueing for footer is not supported. Essentially you need to know if function was called before it was … Read more
You are using a WP_Query object, you just don’t know it (yet). WordPress generates a global called $wp_query which is WP_Query object. This object is what is responsible for what is called the “main Loop” colloquially. This $wp_query object is present on every page that I am aware of. Functions like the_post, have_posts, and some … Read more
The default version of the WordPress function provides the count of the default post type ‘POST’ as stated below: <?php $post_count = count_user_posts($userid); ?> For retrieving the post count based on a post type a custom function as below is required: <?php function count_user_posts_by_type( $userid, $post_type=”post” ) { global $wpdb; $where = get_posts_by_author_sql( $post_type, true, … Read more