• Hey everybody,

    So first, I tell you what I want to do. I want to query all the posts from my Custom-Post-Type which is named “work”. And I want to Paginate them…means I want to have Pagination.

    Later on, maybe when this step works, I also want to show only posts from a special Taxonomy. But for now the Pagination is the important part.

    That’s the code I tried my best on so far:

    <?php
    $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
    $args=array(
    ‘post_type’ => ‘work’,
    ‘post_status’ => ‘publish’,
    ‘posts_per_page’ => 16,
    ‘caller_get_posts’=> 1,
    ‘paged’=>$paged
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
    while ($my_query->have_posts()) : $my_query->the_post(); ?>

    <div class=”workposts”>
    ” title=”<?php the_title() ?>”><?php $image = get_post_meta($post->ID, “Image1”, true); echo $image; ?>
    <h3>” title=”<?php the_title() ?>”><?php the_title() ?></h3>
    <?php $subtitle = get_post_meta($post->ID, “Subtitle”, true); echo $subtitle; ?>
    </div>

    <?php endwhile; } ?>

    <div class=”navigation”>
    <div class=”alignleft”><?php previous_posts_link(‘« Previous’) ?></div>
    <div class=”alignright”><?php next_posts_link(‘More »’) ?></div>
    </div>

    But it just does not work. Any suggestions or ideas ? It would be sooooo cool of you to help me. Thank you very much,

    joeybottle

Viewing 3 replies - 1 through 3 (of 3 total)
  • I don’t know why your code does not work, but have you tried using just query_posts() instead of new WP_Query()? That may make a difference.

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args=array(
    'post_type' => 'work',
    'post_status' => 'publish',
    'posts_per_page' => 16,
    'caller_get_posts'=> 1,
    'paged'=>$paged
    );
    query_posts($args);
    if( have_posts() ) {
    while (have_posts()) : the_post(); ?>
    
    <div class="workposts">
    " title="<?php the_title() ?>"><?php $image = get_post_meta($post->ID, "Image1", true); echo $image; ?>
    <h3>" title="<?php the_title() ?>"><?php the_title() ?></h3>
    <?php $subtitle = get_post_meta($post->ID, "Subtitle", true); echo $subtitle; ?>
    </div>
    
    <?php endwhile; } ?>
    
    <div class="navigation">
    <div class="alignleft"><?php previous_posts_link('? Previous') ?></div>
    <div class="alignright"><?php next_posts_link('More ?') ?></div>
    </div>

    What happens when you click a pagination link? A link to your site so we can see the results might also help.

    Thread Starter joeybottle

    (@joeybottle)

    Okay! The problem is with the permalinks. The pagination works on the first page, but when I click on “more” to see the older posts an error page comes up.

    When I set the permalinks to “default” it seems to work fine. Then I’ll get to the right site and I see the other posts. Any suggestions how to solve that with the “clean” permalinks ????

    Thread Starter joeybottle

    (@joeybottle)

    …and the next step:

    When you name the SITE where this query is on exactly as the new custom-post-type it does NOT work. But if you give it another name it works. That’s kind of strange! Any new suggestions ???

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Special query for custom Post-Type…Difficult, please help!’ is closed to new replies.