Multiple search queries on one page

You can use pre_get_posts to modify the main query, but you will need to create new queries for the other searches. Use get_query_var(‘s’) to get the search terms and create new WP_Query objects to perform your search. Without more information it is hard to provide much more detail to the answer.

Example Query Posts Showing the Latest Post with the Featured Image

Getting most recent post in WordPress have builtin function named wp_get_recent_posts( $args, $output ). So let’s try with this function to get most recent 5 post $args = array( ‘numberposts’ => 5, ‘offset’ => 0, ‘category’ => 0, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘suppress_filters’ => true ); OR … Read more

Prevent change with new query_posts()

You shouldn’t be using query_posts() at all. From the documentation: Note: This function will completely override the main query and isn’t intended for use by plugins or themes. Its overly-simplistic approach to modifying the main query can be problematic and should be avoided wherever possible. In most cases, there are better, more performant options for … Read more

Query for posts in 2 taxonomies

According to the Codex, here’s how you would query posts from several taxonomies: ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘videoscategory’, ‘field’ => ‘slug’, ‘terms’ => $custom_term->slug ), array( ‘taxonomy’ => ‘yourothertaxonomy’, ‘field’ => ‘slug’, ‘terms’ => $other_custom_term->slug ) )

Show Posts From Same Category OR Same Tag

You can achieve that with a tax_query with OR relation. See the Taxonomy Parameters section for WP_Query in Codex for the different tax query parameters. $args = array( ‘tax_query’ => array( ‘relation’ => ‘OR’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => array( ‘fruit’ ) ), array( ‘taxonomy’ => ‘post_tag’, ‘field’ => ‘slug’, ‘terms’ … Read more

Inserting Post Using wp_insert_post. How to Fill Yoast Plugin SEO Fields

You can use the update_post_meta function to insert the Yoast Plugin data. Yoast uses 3 post meta keys for each post: _yoast_wpseo_title ( use for SEO title ) _yoast_wpseo_focuskw (For meta keywords ) _yoast_wpseo_metadesc (For meta descriptio ) You can find all these meta key under postmeta table $new_id = wp_update_post($array); update_post_meta( $new_id, ‘_yoast_wpseo_title’, ‘SEO … Read more

query recent posts from several categories

simply add this above your loop $args = array( ‘posts_per_page’ => 10, ‘category__in’ => array( 2, 6 ), //change and add the category ids here ‘orderby’ => ‘date’, ‘order’ => ‘ASC’) query_posts($args); and you can read more about query_posts Parameters http://codex.wordpress.org/Function_Reference/WP_Query#Parameters Update By popular demand 🙂 here is another example to doing the same but … Read more

pre get posts changing the query

Try using meta_query parameter : add_action(‘pre_get_posts’, ‘add_event_date_criteria’); function add_event_date_criteria(&$query) { // We only want to filter on “public” pages // You can add other selections, like here: // – Only on a term page for our custom taxonomy if (!is_admin() && is_tax(‘event-tag’) || is_tax(‘event-category’)) { $time = time(); $meta = array( array( ‘key’ => ‘start_time’, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)