Custom post types instead of regular post’s categories in a page template

I believe the problem is how you are using this code: $args = array(‘post_type’ => array( ‘make’, ‘model’, ‘price’ ), ‘showposts’=>100, ‘orderby’=>’date’); $type_posts = new WP_Query($args); You may want to change it to something like this: $args = array(‘post_type’ => array( $post_type ), ‘showposts’=>100, ‘orderby’=>’date’); $type_posts = new WP_Query($args); So that it only grabs posts … Read more

Sorting multiple custom post types without a meta key/value pair by sort order

What ended up working is adding the array key, “orderby” and adding menu_order: <?php // query for vidoes in the home page category $args = array( ‘post_type’ =>array(‘videos’, ‘podcasts’), ‘category_name’ => ‘Videos on Homepage’, ‘post_per_page’ => 4, ‘order’ => ‘DESC’, ‘orderby’ => ‘menu_order’, ); $loop = new WP_Query($args); // start loop for first set of … Read more

Create dropdown list post

Hey @Ruriko … its a 3 step action. get the current category ID get the posts for this specific category get the posts into a select menu Please note that this code would use the first category id altough you might assign several categories to the same post. . <?php // FIRST CATEGORY NAME $category … Read more

How to paginate posts correctly that belong to a particular category and are random ordered

You can use the add_filter line inside the template itself & no filter in the “functions.php” file. Then just after retrieving the posts remove that filter with a call to remove_filter. The actual function may still reside in the functions.php file add_filter(‘posts_orderby’, ‘edit_posts_orderby’); // get all the posts for this specific loop here remove_filter(‘posts_orderby’, ‘edit_posts_orderby’); … Read more

How to query a custom post type with a taxonomy filter but display post type archive page?

The simplest way is, in all honesty, to hook into wp_title and change things, and just be aware that the warnings are there but not showing in production (because you’ve property configured your server). What follows is a kind of hacky solution. If you take a look at get_queried_object… <?php function get_queried_object() { global $wp_query; … Read more

orderby:date not working

You should not have to specify orderby=date. That is the default. If you look at the query, you will see that the field used is post_date, which is the publication date and not the modification date– post_modified. You can prove this just by dumping $wp_query after your call to query_posts. Or try: $q = new … Read more

Custom query works but returns “Undefined Offset: 0”

Try like this : $args = array( ‘post_type’ => ‘car’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘your category/taxonomy name for post type car’, ‘terms’ => ‘term name/category name’, ‘field’ => ‘slug’ ) ) ); $query = new WP_Query($args); $results = $query->get_posts(); print_r($results); Yes every post has different slug, even if you have … Read more

Query post order by post and desc not working

post is not a valid value for orderby parameter neither DESC. You can choose any of these values. Also, you should stop using query_post. <?php $args = array( ‘post_type’ => ‘ranking’, ‘orderby’ => ‘menu_order’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 10, ‘meta_key’ => ‘top10’, ‘meta_value’ => ‘sim’ ); $loop = new WP_Query( $args ); while ( … Read more

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