Hello to all, welcome to therichpost.com. In this post, I will tell you, WordPress Custom Query get Posts based on Post Title.
I personally like WordPress very much and you can find many post related to WordPress Tricks, WordPress Hooks, WordPress.
There are many ways to WordPress Posts but sometime we need to get WordPress Posts with custom mysql query and this is also good way.
Today I am showing you custom mysql query to get WordPress Posts based on Post Title and Post Type.
global $wpdb; $yourPostTitle=$_GET['s']; $query = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_title LIKE '%$yourPostTitle%' AND post_type='product' AND post_status='publish'"); foreach ($ids as $data) { $url = wp_get_attachment_url( get_post_thumbnail_id($data->ID), 'full' ); // Post Thumbnail ?> <a href="<?php echo get_permalink($data->ID); ?>"><img src="<?php echo $url ?>" /></a> // Post Link <h2><a href="<?php echo get_permalink($data->ID); ?>"><?php echo $data->post_title; ?></a></h2> // Post Title <?php }
If you have any query related to this post, then please do comment below ask question.
Jassa Jatt,
Thank you
Recent Comments