Retrieve posts in custom post type and specific taxonomies

Both get_posts() and wp_query() should be able to do this by passing the tax_query array into them. Example: $query = array( ‘post_type’ => ‘portfolio’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘clients’, ‘field’ => ‘slug’, ‘terms’ => array( ‘acme’ ) ) ), ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’ ); $posts … Read more

Sort by name – second wp_query

Posts are not sorted alphabetically, because you don’t tell WordPress to sort them in such way. By default they will be sorted by date in descendant order (newest first). What you should do, is change your WP_Query args by adding order and orderby, so it should look like this: $args = array( ‘post_type’ => ‘os_book’, … Read more

What is wrong with this pagination code?

The main query runs before the template is loaded, and WordPress decides what template to load based on the results of that query. You say your default posts_per_page is set to 200, and there are 180 posts in that category, so as far as WordPress knows, there is no page 2. Your custom query that … Read more

wp_query for more fields plugin

More fields Plugin is to enter additional input into the post, page etc. And that is Custom Fields in WordPress. To use WP_Query() for those Custom Fields input, you have to query for the meta_key. <?php //Query for only my custom field value $args = array( ‘meta_key’ => ‘your_field_key’ ); $wpse_query = new WP_Query($args); while( … Read more

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