How to get 4 Posts after the 5 most recent ones

Simple. WordPress provides a function called get_posts() that lets you get posts in any order. Basically, get_posts() will retrieve the 5 most recent posts by default. To get 4 posts, ignoring the 5 most recent, you’d set the numberposts and offset parameters – offset tells the function how many posts to skip. $args = array( … Read more

How to order posts by slug using query_posts/ Wp_query

In WordPress the post slug is saved in database with name post_name, so to sort posts by slug just use: orderby=name. Edit: Here’s the example of query: $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 10, ‘orderby’ => ‘name’ ); $query = new WP_Query( $args );

exclude ids through post__not_in

Your PHP is wrong. function slider_exclude(){ $exclude_query = query_posts(array(‘showposts’ => 4, ‘cat’ => ‘news’,)); foreach($exclude_query as $post_ids){ return $post_ids->ID.’,’; } } Looks like you are trying to build a comma delimited string but that isn’t how return works. When that foreach hits the return the function returns– it ends. Nothing else gets processed. You need … Read more

‘category__and’ for custom taxonomy?

I think this question can cause a misunderstanding. You say: I want to retrieve all the posts that have custom taxonomies ‘taxonomy-1’ and ‘taxonomy-2’ but do you want post that have both taxonomy-1 and taxonomy-2 and taxonomy-3 is irrilevant? $args = array( ‘post_type’ => ‘post-type-x’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘taxonomy-1’, … Read more

WP query exclude post within the last month / only show over 1 month old

The date query for WP_Query supports several options, including before and after. Using just before, you can fetch posts from before a certain date (excluding posts from that date on): $args = array( ‘date_query’ => array( array( ‘column’ => ‘post_date_gmt’, ‘before’ => ‘1 month ago’ ) ), ‘posts_per_page’ => -1, ); Furthermore, you can specify … Read more

How to display recent posts added in several custom post types

You can pass multiple custom post types in an array for ‘post_type’, as in: ‘post_type’ => array(‘books’, ‘stories’, ‘movies’) Your code seems to try to do this, but the syntax is a bit off, it should be: $recent_posts = wp_get_recent_posts( array( ‘post_type’ => array( ‘books’, ‘stories’, ‘movies’ ), ) ); You can find more details … Read more

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