Query unique author ids with published post of type job
The most efficient means would be to query directly via wpdb: $author_ids = $wpdb->get_col( ” SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_type=”job” AND post_status=”publish” ” );
The most efficient means would be to query directly via wpdb: $author_ids = $wpdb->get_col( ” SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_type=”job” AND post_status=”publish” ” );
The problem here is not that the posts that are being wrongly displayed are displayed under the wrong category, it’s that they’re not actually in the right category. For example, the post “Supporting healthy eating choices” is displayed under “O” as it has the category “O”. Going to your backend and assigning the proper category … Read more
function exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘cat’, ‘-5377’ ); $query->set( ‘orderby’, ‘date’ ); $query->set( ‘order’, ‘DESC’ ); } } add_action( ‘pre_get_posts’, ‘exclude_category’ ); Use ASC or DESC for order. Add code to child themes functions file. Tested and works.
Try adding the following code to the top of your search.php template below the get_header() call: <?php global $query_string; $query_args = explode(“&”, $query_string); $search_query = array(); foreach($query_args as $key => $string) { $query_split = explode(“=”, $string); $search_query[$query_split[0]] = urldecode($query_split[1]); } // foreach $search = new WP_Query($search_query); ?>
Here’s what I’d do. This is mildly tested. It gets the IDs of all the posts you need and then builds a single query to get the posts in the correct order. // get your page IDs, I assume this returns an array of integers $page_ids = get_pageslug(” ‘first_page’, ‘second_page’ “); // get your blog … Read more
You have to use JOIN for that. Try it like this: $wpdb->get_results(“SELECT tags.*, $wpdb->posts.*, $wpdb->postmeta.* FROM tags INNER JOIN $wpdb->posts ON tags.charity_id = $wpdb->posts.ID INNER JOIN $wpdb->postmeta ON tags.charity_id = $wpdb->postmeta.post_id WHERE tags.charity_id = $charity_id” );
Archive query not working correctly
Ok here’s my altered function but this one doesn’t work at all but maybe you can see wher i go wrong function insertUserShoppingMetaData($params) { global $wpdb; $shopping_meta_table=”wp_shopping_metavalues”; $wp_user_id = $params[‘wp_user_id’]; $checkKeyValues = $wpdb->get_results(“SELECT meta_shopping_key FROM $shopping_meta_table WHERE wp_user_id = ‘$wp_user_id'”); //print_r($checkKeyValues); foreach ($params as $key => $val) { foreach($checkKeyValues as $check){ //UPDATE OR INSERT if … Read more
Why are you using $wpdb to query from database. Use WP_Query or get_posts instead. This is how you can query from WordPress database and get 4 latest posts from category id 24. <?php $args = array( ‘post_type’ => ‘post’, ‘cat’ => 24, ‘posts_per_page’ => 4, ‘ignore_sticky_posts’ => 1 ); $my_query = new WP_Query( $args ); … Read more
It sounds like what you really might want is a transient. WP Transients are a way to cache the results of a query, and set an expiration date on that cache. So you could cache the results of your example from above for 24 hours. If anyone requests that data while the cache is still … Read more