Why Query is returning empty array?
you may need to wrap $slug in quotes $course = $wpdb->get_results( “SELECT * FROM wp_posts where post_name=”$slug”” );
you may need to wrap $slug in quotes $course = $wpdb->get_results( “SELECT * FROM wp_posts where post_name=”$slug”” );
So from the WP_Query page, I found this, which is like $args[‘name’] but for when you want to search for many slugs: post_name__in (array) – use post slugs. Specify posts to retrieve. (Will be available in version 4.4) I think this is maybe what you need? In that case you’d need to explode $atts[‘post’] on … Read more
It shows more than 3 posts because you used post_per_page when it should be posts_per_page (note the plural “posts”). But actually, you can use the same query and use a counter to display the different template parts: $loop = new WP_Query( array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 5, ) ); $c = 1; // post … Read more
From what I could see, the query did return a result, but the COALESCE() result was not named, hence MySQL and WordPress use the entire COALESCE() query as the field name. To avoid that, you would use an alias for the COALESCE(), e.g. //$query = “SELECT COALESCE( <your queries> ) AS <alias>”; $query = “SELECT … Read more
What about this one? function opby_query( $query ) { if ( $query->is_main_query() ) { if ( $query->is_home() ) { $query->set(‘posts_per_page’, 15); }; if ( isset( $query->query_vars[‘ctrl_podcasts_status’] ) ) { // get main query args $subquery_args = $query->query_vars; // add tax_query filter $subquery_args[‘tax_query’] = array( array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => array( ‘podcast-control-daily’ … Read more
The reason is due to this code inside dbDelta() : // Create a tablename index for an array ($cqueries) of queries. foreach ( $queries as $qry ) { if ( preg_match( ‘|CREATE TABLE ([^ ]*)|’, $qry, $matches ) ) { $cqueries[ trim( $matches[1], ‘`’ ) ] = $qry; $for_update[ $matches[1] ] = ‘Created table ‘ … Read more
Note that a filter callback must always return something which is commonly the first parameter passed to the callback. So for example your overwriteQueryVars() function, it must always return the $query because request is a filter hook. Secondly, instead of overwriting the entire query arguments (e.g. by doing $query = array( … ) or $query->query_vars … Read more
Just to clear this up for someone that might have similar problem, everything was find with query, the problem with this was WordPress was looking for WP_Query class in namespace file, replacing new WP_Query with new \WP_query solved this problem 😀 thanks for help!
I can’t seem to find a way to set the query more than one taxonomy You already found it, but the problem is, you should have not done this: $tax_query_array = array(‘relation’ => ‘OR’); $speciality_select ? array_push($tax_query_array, …) : null ; $query->set( ‘tax_query’, $tax_query_array); $tax_query_array = array(‘relation’ => ‘OR’); $industry_select ? array_push($tax_query_array, …) : null … Read more
I’m not sure why you’d want a post you’re already looking at to be in the similar… but off topic I guess. You ask it not to include the $current_id in this line here if ( $score > 90 && get_the_ID() != $current_id ) {