How to query search only for post titles?

Try this $posts = $wpdb->get_results(“SELECT * FROM “.$wpdb->prefix.”posts WHERE post_title LIKE ‘%” . $_REQUEST[‘s’] .”%’ AND post_status=”publish” AND post_type=”post””); $do_not_duplicate = $post->ID; foreach($tit as $post) { if( $post->ID == $do_not_duplicate ) continue; ?> Please let me know if any query. Hope it will help you!

How to compare between two dates in a nested loop?

That date format will be a problem for wp_query because it’s a string in the format d-m-y. Your meta_query is close but the key needs to be the field name, and the stored date format must be yyyy-mm-dd: ‘meta_query’ => array( array( ‘key’ => ‘usp-custom-51’, ‘value’ => array($start, $end), ‘compare’ => ‘BETWEEN’, ‘type’ => ‘DATE’ … Read more

Query child posts with tax query on parents

My solution to this ended up splitting this into 2 queries: Get the IDs of all the parent products I want to ignore Get all the variations that don’t a post_parent from that list of IDs $archived_products = wc_get_products( array( ‘type’ => array( ‘variable’, ‘variable-subscription’ ), ‘paginate’ => false, ‘limit’ => -1, ‘category’ => array( … Read more

WP_Query & Duplicate entries

There shouldn’t be a foreach loop inside the while. The while loops over posts, so you don’t need another foreach. The while loop in this context is what WordPress calls “The Loop”. See the section of documentation for The Loop on secondary queries here. So your loop should look like this: <?php while ( $posts->have_posts() … Read more

custom excerpt is not being shown

One thing that can be happening is if you have added a Read more tag in your content it is overriding the manual excerpt. just check and see if you have <!–more–> tag in your content body. if so remove it. The next thing is the_excerpt()may use auto generated excerpt. it is said in Wp … Read more

Case insensitive ORDERBY in wpquery

As stated above, your orderby parameter should be set to meta_value, not restaurant. Using phpMyAdmin or some other tool, look at your database. With any newer installation of WordPress, your tables should have a collation of utf8mb4_unicode_ci. That means that the table is storing its data in UTF-8 4-byte unicode character set. That “ci” at … Read more