wordpress udpate query not equal to
This is not something $wpdb->update() method implements. If you have custom SQL query that cannot be expressed in API you can run it as is with generic $wpdb->query().
This is not something $wpdb->update() method implements. If you have custom SQL query that cannot be expressed in API you can run it as is with generic $wpdb->query().
Never re-do the main query. Hook into pre_get_posts and change it. The following needs to go in your functions.php (putting in the template will mean it runs too late): add_action( ‘pre_get_posts’, function ( $wp_query ) { if ( $wp_query->is_main_query() && $wp_query->is_tag() ) { $wp_query->set( ‘posts_per_page’, 20 ); $wp_query->set( ‘post_type’, [ ‘pavilion’, ‘post’, ‘catalog’, ‘tenders’, ‘services’, … Read more
You might want to go through: https://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters So using tag parameter in WP_Query, you can get posts tagged to ‘video’ tag. Use orderby and posts_per_page to get last 5 video posts. $query = new WP_Query( array( ‘tag’ => ‘video’, ‘posts_per_page’ => 5 ) ); while ($wp_query->have_posts()) : $wp_query->the_post(); //your code to display posts endwhile; Haven’t … Read more
Both methods are okay ($new_wpdb->insert actually uses $new_wpdb->prepare) and provide the same level of safety when it comes to SQL escaping. $new_wpdb->insert is the preferred method unless you’re writing your own custom SQL query.
Sounds like you’ve already done all of the heavy lifting. function_exists() expects a string for the first parameter, so custom_pagination should be ‘custom_pagination’ (add quotes): if ( function_exists( ‘custom_pagination’ ) ) { …
From your supplied info, it’s not all very clear to me. But as far as I’ve understood your problem, here’s my approach. Assuming we have the following shortcode that the user has put inside a normal post’s content and that this shortcode will pull information from your custom post type case_studies: [casestudy study_type=”mountain”] So firstly, … Read more
Finally, I figure it out. It seems that the get_posts and query_posts accept different arguments, when I use the get_posts I can setup the arguments like this: get_posts(array( “category” => $cate->term_id, “numberposts” => 12 )); While when I use query_posts I have change that to: query_posts(array( “cat” => $cate->term_id, “numberposts” => 12 )); Notice the … Read more
First you can optimize a little by not joining with wp_users as the joins can all be done between wp_usermeta. Another optimization would be to replace the WHERE clause with a subselect (which MySQL manages to optimize so it only gets executed once). The meta_key clause parts should be put into the WHERE clause I … Read more
Try this code <?php $args = array( ‘s’ => $_REQUEST[ ‘search’ ], ‘cat’ => ‘category_id’, ‘paged’ => $paged ); // The Query $the_query = new WP_Query( $args ); // The Loop while ( $the_query->have_posts() ) : $the_query->the_post(); //inside the loop the_title(); the_content(); endwhile; // Reset Post Data wp_reset_postdata(); ?> Hope this help
You are getting all post because you didn’t pass meta query correctly. Try this below code function add_search_in_custom_fields( $query ) { // check the query type. if ( $query->is_search ) { $meta_array = array( array( ‘key’ => ‘my_key_title’, ‘value’ => $query->query_vars[‘s’] , ‘compare’ => ‘LIKE’, ), ); // set meta query. $query->set(‘meta_query’, $meta_array); }; } … Read more