定义了特定Post_类型的帖子中的页面导航在Wordpress中不起作用

定义了特定Post_类型的帖子中的页面导航在Wordpress中不起作用,wordpress,navigation,pagination,custom-post-type,Wordpress,Navigation,Pagination,Custom Post Type,那篇文章有好几页使用Wordpress的快速标签。此帖子也是自定义帖子类型。。在主题模板的functions.php中使用以下代码 add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'gallery', array( 'labels' => array(

那篇文章有好几页使用Wordpress的快速标签。此帖子也是自定义帖子类型。。在主题模板的functions.php中使用以下代码

add_action( 'init', 'create_post_type' );
    function create_post_type() {
        register_post_type( 'gallery',
            array(
                'labels' => array(
                'name' => __( 'Galleries' ),
                'singular_name' => __( 'Gallery' )
            ),
            'public' => true,
            'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments')
            )
        );
有了这段代码,我成功地在管理部分获得了一个自定义的帖子类型。我在那里添加了一篇新文章,带有翻页器

因此,使用wp_link_pages()函数,我使页面翻转函数工作。但它只适用于类别下的常规帖子,而不适用于定义为“画廊”帖子类型的帖子。例如,此页面与文章中的分页配合得很好

我没有使用任何影响后期显示方法或导航的插件,我也没有弄乱.htaccess文件——Wordpress写的东西就是我得到的

任何帮助都会很好。。网站几乎准备好了,我们遇到了这个瓶颈,我快死了

我使用的是Wordpress的最新版本,我开始开发白板主题(为WP3制作的新主题)。]

更新: php(通过页面模块分配以显示post_类型的“gallery”-我确认这是在加载gallery post_类型的帖子时加载的文件)



您遇到的问题是使用自定义文章类型分页。这里有一个例子和解决方案,用来让它工作

一个类似的问题已经得到了回答


编辑:

我无法使用您提供的代码重现错误。 见:

为了创建测试,我采取了以下步骤:

  • 从主题主页上载并安装了白板主题

  • 添加了提供给functions.php的示例代码以创建post类型

  • 复制了提供的代码“Gallery Template”,并将其重命名为single-Gallery.php

  • (显示单个post类型页面时,模板层次结构先查找single-PostType.php,然后查找single.php)

  • 通过单击“库”“添加新库”创建新库

  • 使用添加介质插入4个图像

  • 在每个图像之间插入

  • 保存的帖子和更新的永久链接

  • 测试环境

    • WordPress版本:3.0.1
    • PHP版本:5.2.13
    • 主题:白板
    • 永久链接:/%year%/%monthnum%/%postname%/

    难以置信。没有人有这个答案?我尝试了WP论坛、Google和Stack Overflow。一定有人在那里!你为什么不试试把这个发到。新的StackExchange beta站点之一。您可以发布用于单个自定义发布类型的模板吗?是否与用于常规帖子的single.php相同?添加。我甚至不知道有一个WP回答网站。我可能会这样做。谢谢你-但是你的Wordpress线程与许多帖子的分页有关,而不是一篇被quicktag分割的帖子内的分页。和我的完全不同,所以。我找到的教程在编写过程中出错了。传递到模板文件的正确方法是只使用single-gallery.php文件名,而不是设置页面和链接模板等。
    <?php
    /*
    Template Name: Gallery
    */
    ?>
    
    <?php get_header();
    
    $exclude = array();
    
    ?>
    <div class="grid_11" id="mainbar">
    
    
    
        <?php if ( have_posts() ) while ( have_posts() ) : the_post();
    
        $exclude[]=get_the_ID();
        ?>
                <div id="post-<?php the_ID(); ?>" <?php post_class('grid_11 alpha omega'); ?>>
                    <h2><a href="<? the_permalink(); ?>" title="<? the_title();?>"><? the_title();?></a></h2>
                    <div class="social_media_balloons">
                    <?
                    if (function_exists('fbshare_manual')) echo fbshare_manual();
                    ?>
                    <?
                    if (function_exists('tweetmeme')) echo tweetmeme();
                    ?>
                    </div>
                        <?
                        $author_gravatar = get_gravatar(get_the_author_meta('user_email'));
                        ?>
                        <img src="<? echo $author_gravatar;?>" class="alignleft" />
                <?
                echo posted_by_and_category();
    
                ?>
    
                        <div class="grid_11 alpha omega">
    
                            <?php the_content(); ?>
                            <div id="single_article_selectors">
    
                            <?php wp_link_pages('before=<div class="single_article_selector">&after=</div>'); ?>
                            <?php wp_link_pages('before=<div class="single_article_selector">&after=</div>&next_or_number=next'); ?>
    
                            </div>
    
                            <div class="grid_11 alpha omega" id="social_media_links">
                            <div class="grid_5 alpha">
                                <p><a href="http://www.twitter.com/LakersNation" target="_blank"><img src="/images/twittericon.jpg" alt="Twitter" width="32" height="32" class="alignleft">Follow Lakers Nation </a></p>
                                <p><a href="http://feeds.feedburner.com/LakersNation" target="_blank"><img src="/images/rssicon.jpg" alt="Twitter" width="32" height="32" class="alignleft">Subscribe to Lakers Nation</a></p>
                            </div>
                            <div class="grid_5 omega">
                                <p><a href="http://www.facebook.com/lakersnation" target="_blank"><img src="/images/fbicon.jpg" alt="Twitter" width="32" class="alignleft">Become a Fan on Facebook</a></p>
                                <p><a href="http://itunes.apple.com/us/app/app-of-l-nation/id349346678?mt=8" target="_blank"><img src="/images/iphoneicon.png" alt="Twitter" width="32" height="32" class="alignleft">Download our Free iPhone App</a></p>
                            </div>
                        </div>
    
    
                            <div class="shadow_divider"></div>
                        </div><!--#post-content-->
    
                        <!-- If a user fills out their bio info, it's included here -->
                        <div id="post-author" class="grid_11 alpha omega">
                            <h3>Written by <?php the_author_posts_link() ?></h3>
                            <div id="author-gravatar">
                                <!-- This avatar is the user's gravatar (http://gravatar.com) based on their administrative email address -->
                                <?php echo get_avatar( $curauth->user_email, $default = '<path_to_url>' ); ?>
                            </div><!--#author-gravatar -->
                            <div id="authorDescription">
                                <?php the_author_meta('description') ?> 
                                <div id="author-link">
                                    <p>View all posts by: <?php the_author_posts_link() ?></p>
    
                                </div><!--#author-link-->
                            </div><!--#author-description -->
                        </div><!--#post-author-->
    
                    </div><!-- #post-## -->
    
                    <div class="grid_11 alpha omega next_prev_links">
                        <div class="grid_3 alpha">
                            <p>
                                <?php previous_post_link('%link', '&laquo; Previous post') ?>
                            </p>
                        </div><!--.older-->
                        <div class="grid_3 omega" style="float:right; text-align:right;">
                            <p>
                                <?php next_post_link('%link', 'Next Post &raquo;') ?>
                            </p>
                        </div><!--.older-->
                    </div><!--.newer-older-->
    
                    <?php comments_template( '', true ); ?>
    
        <?php endwhile; ?><!--end loop-->
    </div><!--#content-->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    
    <?php get_header();
    
    $dirpath = str_replace(get_bloginfo('url'), '',get_bloginfo('template_directory'));
    ?>
    <div class="grid_11" id="mainbar">
    
    
    
        <?php if ( have_posts() ) while ( have_posts() ) : the_post();
    
        $exclude[]=get_the_ID();
        ?>
    
                <div id="post-<?php the_ID(); ?>" <?php post_class('grid_11 alpha omega'); ?>>
    
                <?
                echo posted_by_single();
                ?>
                <div class="grid_11 alpha omega">
                    <div id="single_post_title">
                    <h1><a href="<? the_permalink(); ?>" title="<? the_title();?>"><? the_title();?></a></h1>
    
                    </div>
                    <div class="social_media_balloons">
                    <?
                    if (function_exists('fbshare_manual')) echo fbshare_manual();
                    ?>
                    <?
                    if (function_exists('tweetmeme')) echo tweetmeme();
                    ?>
                    </div>
    
                    <div class="grid_11 alpha omega">
    
                        <?php the_content(); ?>
                        <div id="single_article_selectors">
    
                        <?php wp_link_pages('before=<div class="single_article_selector">&after=</div>'); ?>
                        <?php wp_link_pages('before=<div class="single_article_selector">&after=</div>&next_or_number=next'); ?>
    
                        </div>
    
                        <div class="grid_11 alpha omega" id="social_media_links">
                            <div class="grid_5 alpha">
                                <p><a href="http://www.twitter.com/LakersNation" target="_blank"><img src="/images/twittericon.jpg" alt="Twitter" width="32" height="32" class="alignleft">Follow Lakers Nation </a></p>
                                <p><a href="http://feeds.feedburner.com/LakersNation" target="_blank"><img src="/images/rssicon.jpg" alt="Twitter" width="32" height="32" class="alignleft">Subscribe to Lakers Nation</a></p>
                            </div>
                            <div class="grid_5 omega">
                                <p><a href="http://www.facebook.com/lakersnation" target="_blank"><img src="/images/fbicon.jpg" alt="Twitter" width="32" class="alignleft">Become a Fan on Facebook</a></p>
                                <p><a href="http://itunes.apple.com/us/app/app-of-l-nation/id349346678?mt=8" target="_blank"><img src="/images/iphoneicon.png" alt="Twitter" width="32" height="32" class="alignleft">Download our Free iPhone App</a></p>
                            </div>
                        </div>
    
                        <div class="shadow_divider"></div>
                    </div><!--#post-content-->
    
    
                </div><!-- #post-## -->
    
    
    
                    <div class="grid_11 alpha omega next_prev_links">
                        <div class="grid_3 alpha">
                            <p>
                                <?php previous_post_link('%link', '&laquo; Previous post') ?>
                            </p>
                        </div><!--.older-->
                        <div class="grid_3 omega" style="float:right; text-align:right;">
                            <p>
                                <?php next_post_link('%link', 'Next Post &raquo;') ?>
                            </p>
                        </div><!--.older-->
                    </div><!--.newer-older-->
                <div class="grid_11 alpha omega" id="comments_container">
                <?php comments_template( '', true ); ?>
                </div>
            </div>
        <?php endwhile; ?><!--end loop-->
    </div><!--#mainbar-->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>