Custom taxonomy query not working with switch_to_blog

I find the solution: Tax_query not working on multisite (I dont say, that I work with switch_to_blog, because everything is works fine with this function… everything, including postmeta queries, category__not_in, etc., but EXCEPT: tax_query) So, “you have to register that custom taxonomy in both blogs”. <– so the problem originate from the different themes, when … Read more

Modals using loops and ACF [closed]

You’re right you should be using an id. I would use a counter in conjunction with get_the_ID(); $arr_posts = new WP_Query( $args ); if ( $arr_posts->have_posts() ) : $index = 0; while ( $arr_posts->have_posts() ) : $arr_posts->the_post(); echo $index . ‘_’ . get_the_ID(); endwhile; endif; This will give you a unique id which you can … Read more

Using $wpdb->update but confused on the WHERE in and SET

You need to look at the documentation for the function, which is available here. The function takes the following arguments: $table The table name. $data A PHP array where the keys are the columns and the values are the the values to be inserted into those columns. $where A PHP array where the key is … Read more

Strange string in console from wpdb query

That is a placeholder escape string generated by wpdb::placeholder_escape() which is used by wpdb::add_placeholder_escape() and which is called by wpdb::prepare(). So it is safe to keep those escape strings, but there is a wpdb method for removing them: wpdb::remove_placeholder_escape(): // In your case, you’d use $this->wpdb in place of $wpdb. $query = $wpdb->add_placeholder_escape( ‘LIKE %night%’ … Read more

How to find exact match for search term in WP_Query? What is the additional string added in LIKE query in WP_Query?

it adds additional value before and after each Like query That {d146fc7cb41ff444163abadd50ac5da7ec5439fd51386c3cfe2cea107126703b} is a placeholder escape string for the literal % (percent) sign used in prepared statements (see wpdb::prepare()) and the escape string is generated by wpdb::placeholder_escape(). So actually, that {d146fc7cb41ff444163abadd50ac5da7ec5439fd51386c3cfe2cea107126703b} is the % sign, but in an escaped form, and it will be changed … Read more

Disallow categories from this MySQL query

You could use the get_tax_sql() function introduced in WP 3.1: $tax_query = array( array( ‘taxonomy’ => ‘category’, ‘terms’ => array( 4, 6, 7, 9 ), ‘operator’ => ‘NOT IN’ ) ); $clauses = get_tax_sql( $tax_query, $wpdb->posts, ‘ID’ ); … “SELECT ID, post_date, post_date_gmt, comment_status, comment_count FROM $wpdb->posts {$clauses[‘join’]} WHERE post_status=”publish” AND post_type=”post” {$clauses[‘where’]} ” … … Read more

Query all posts which do not have tags assigned to them

Either use the tag_not_in parameter if you have the tag id and if not then you can use tax_query parameter like so: $tag_to_exclude=”example_tag”; $args = array( ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘post_tag’, ‘field’ => ‘slug’, ‘terms’ => array($tag_to_exclude), ‘operator’ => ‘NOT IN’, ) ); query_posts($args);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)