Hi I am working on a archive page which I can use for multiple custom post types. I need to make a variable in the $args
array which can change to the post_type
name on the basis of
<?php post_type_archive_title(); ?>
So something like this:
<?php
$post_type = post_type_archive_title();
$args = array(
'post_type' => $post_type,
'orderby' => 'title',
'order' => 'ASC',
'caller_get_posts' => 1,
'posts_per_page' => 20,
);
query_posts($args); ?>
But this doesn’t work. Does anyone know how I can fix this?
From WordPress Codex:
“Title of post type” is the label, not the post type registered name.
You can get the registered post type name using
get_queried_object();
like this:I see in your
$args
array, thecaller_get_posts
, if you are using WordPress 3.1+, i suggest you to useignore_sticky_posts
that replaced the previous one. Look this ( pagination parameters ).Maybe i’m wrong maybe not, if you have any problems, reply here : )