0

I'm using the script below to call post from a certain category in the sidebar. It pulls from all post type on the homepage and on the single post page, but when it comes down to the post type archive pages it doesn't show but only from that post type archive in which you are viewing.....I want it to show from all post types not matter what post type archive you are viewing.

<?php
$queryObject = new  Wp_Query( array(
        'showposts' => 4,
        'post_type' => array('pretty-little-liars', 'revenge', 'once-upon-a-time','scandal'),
        'category_name' => celebrity,
            'orderby' => 1,
        ));
// The Loop!
if ($queryObject->have_posts()) {
 ?>
<?php
while ($queryObject->have_posts()){
    $queryObject->the_post();
    ?>

How do i get it to show post from all post type by category on the post type archive page?

4
  • Is the category taxonomy registered for all of the listed custom post types, pretty-little-liars, revenge, once-upon-a-time, and scandal? Do posts of all of these custom post types have posts with the celebrity term in the category taxonomy? Commented Jan 30, 2013 at 12:46
  • Yes, it is registered and, yes they have post under the category celebrity
    – Mihad Aiko
    Commented Jan 30, 2013 at 14:05
  • Also: replace 'showposts' with 'posts_per_page'. The former was deprecated some time ago. Commented Jan 30, 2013 at 14:33
  • I did, but is there ant solution for my problem
    – Mihad Aiko
    Commented Jan 30, 2013 at 22:49

1 Answer 1

0

Change it from:

    'category_name' => celebrity,
    'orderby' => 1,

into

    'category_name' => 'celebrity',
    'orderby' => 'date', // or something else

Otherwise celebrity will be treated as a constant name, not a string. Also, you can't order by 1, you have to use one of the ordering parameters.

7
  • tried this and it's still doing the same thing, It's only showing from that one post type archive instead of all post type archives
    – Mihad Aiko
    Commented Jan 30, 2013 at 12:36
  • it's still not shoing in the archives.... go to Tv-cafe.com and notice the "Latest In Celebrity" and the "Latest Videos" then go to Tv-cafe.com/one-upon-a-time and notice that they aren't showing from all post types
    – Mihad Aiko
    Commented Feb 25, 2013 at 7:24
  • So, when you go to the archive for Post Type A, do you also want to show Post Type B and Post Type C? That's a little odd, but just add 'post_type' => 'any' or 'post_type' => array('post-type-a', 'post-type-b', 'post-type-c') to the arguments array.
    – Simon
    Commented Feb 25, 2013 at 8:29
  • neither of those otions worked :( @Simon
    – Mihad Aiko
    Commented Feb 25, 2013 at 9:16
  • I see now that it was already in you initial arguments, sorry about that. I just tested running a query using array( 'post_type' => 'any', 'category_name' => 'some_cat' ) and it worked out fine, as did using an array of post types. Perhaps all post types you are querying doesn't have the default category taxonomy registered (you need to do that manually), or perhaps the posts are not assigned to the specific category term you are querying?
    – Simon
    Commented Feb 25, 2013 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.