Query_posts $query_string

After some searching I found the parameters I needed: https://gist.github.com/luetkemj/2023628 (on Line 231) //////Search Parameter //http://codex.wordpress.org/Class_Reference/WP_Query#Search_Parameter ‘s’ => $s, //(string) – Passes along the query string variable from a search. For example usage see: http://www.wprecipes.com/how-to-display-the-number-of-results-in-wordpress-search ‘exact’ => true, //(bool) – flag to make it only match whole titles/posts – Default value is false. For more … Read more

Dynamically excluding current page id

In your code, if $post_id were, say, 99, this: query_posts(“showposts=4&post_type=page&post_parent=168&orderby=rand&exclude=”. $post_id .””); would result in this being passed to query posts: query_posts(“showposts=4&post_type=page&post_parent=168&orderby=rand&exclude=”. 99 .””); so, your issue here is ‘. 99 .’ isn’t a valid value for exclude. That said, query_posts should only be used to alter the main loop in a template. if you … Read more

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

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