【问题标题】:WP custom post type navigationWP自定义帖子类型导航
【发布时间】:2015-08-08 18:52:42
【问题描述】:

我有问题。我有一个自定义帖子类型,其中包含类别和导航。 本地主机/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>';
}
?>

【问题讨论】:

    标签: wordpress navigation custom-post-type


    【解决方案1】:

    我认为它是 wp 错误。将其添加到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;
        }
    

    【讨论】:

    • 没有任何改变。相同的 404 .. 我认为,这真的是 wp 错误。但是如何解决它..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-24
    相关资源
    最近更新 更多