Exclude posts based on meta value
post__not_in function is for exclude categoryes. Try with: $query = new WP_Query( ‘post__not_in’ => array( 2, 5, 12, 14, 20 ) ); maybe your problem is in syntax
post__not_in function is for exclude categoryes. Try with: $query = new WP_Query( ‘post__not_in’ => array( 2, 5, 12, 14, 20 ) ); maybe your problem is in syntax
I finally got this one. I’ll write out the solution for any other inexperienced person, like me, who is trying to handle a checkbox array when using just one options array. First, the two articles I linked two at the top of the question are good for learning the basic about the topic. Solution – … Read more
It is trivial to store an array of options in WordPress — just pass an array to option functions. 🙂 The downside is that it will be stored in serialized form, which isn’t friendly for SQL queries. That matters more for other APIs, such as meta data, than options. Converting is up to you, you … Read more
get_page_by_title() source code shows it runs a single mysql query. You can streamline your two calls of the function to be just one query by writing a custom one: global $wpdb; $qry = “SELECT ID FROM $wpdb->posts WHERE (post_title = %s OR post_title = %s) AND post_status=”publish””; $sql = $wpdb->prepare($qry, ‘title1’, ‘title2’ ); $res = … Read more
Your issue has nothing to do with the foreach. The problem is this part: implode( ‘&’, $social_link[‘query’] ) implode() only connects the values. There’s nothing in this code that adds the keys or an =. If you want to add an array of key/values as a query string to a URL, WordPress provides a function … Read more
OK, so this is what I did wrong. This was an array within an array, which meant that I had to use the element index to echo the values. I’m not even sure I’m explaining it right, but thanks for your help all. It’s working now.
I found the solution: My array of IDs + tags is like this: $array_tags_and_ids = [ ‘239’ => [“car”, “animal”, “dog”, “cat”], ‘243’ => [“dsa”, “ewr”, “bvc”, “fgn”] ]; So I do: foreach ($array_tags_and_ids as $key => $value) { // re-call the value and get only the text value $implode_tags_names = implode( ‘, ‘, $value … Read more
What you want to do is create a variable that keeps track of the ‘current’ state, then for each post in the loop check if its state is the same as the current state. If it is not then output it and update the current state to the new state. This will have the effect … Read more
Let’s try the below code, $users = get_all_user_ids(”); $i=0; // initialization foreach($users as $user) { $pageview = get_user_meta($user, ‘page_visits’, true); if ($pageview != 0) { //$popularid[$pageview][‘count’] = $user; // Err: // Array won’t be unique due to pageview might be same for multiple users // $popularid[$user] = $pageview; // Array will be unique based on … Read more
call_user_func_array() error in class-wp-hook.php