WP自定义帖子类型导航

时间:2015-08-08 18:52:42

标签: wordpress navigation custom-post-type

我有问题。我有一个自定义的帖子类型,其中包含类别和导航。 本地主机/ rit_wp / venki / 但是当我去的时候 localhost / rit_wp / venki / page / 2我有404错误。

<?
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
$args = array(
    'post_type' => 'catalog',
    'posts_per_page' => 4,
    'category_name' => get_query_var('category_name'),
    'tax_query' => $tax,
    'paged' => $paged,
    'post_status' => 'publish',
    'caller_get_posts'=> 1
);
$query = new WP_Query( $args );
if ($query->have_posts()) {
    while ($query->have_posts()) {

        $query->the_post(); ?>
        <li>
            <a href="<? the_permalink(); ?>"></a>

            <div class="poster">
                <? the_post_thumbnail('miniThumbnail'); ?>
            </div>
            <h2><?php the_title(); ?></h2>
        </li>

    <?
    }  //endwhile
    ?>


<?
} else {
    echo '<li>Нет материалов</li>';
}
?>

1 个答案:

答案 0 :(得分:0)

我认为它是wp bug。将其添加到functions.php

add_filter('redirect_canonical', 'disable_custom_redirect');

    function disable_custom_redirect ($redirect_url)
    {
        global $post;
        $ptype = get_post_type($post);
        if ($ptype == 'catalog')
            $redirect_url = false;
        return $redirect_url;
    }