【问题标题】:Sidebar Widget Misaligned on Category Pages侧边栏小部件在类别页面上未对齐
【发布时间】:2012-12-05 02:44:16
【问题描述】:

我重新发布了同样的问题,但我最好定义问题。

基本上,我试图限制出现在我的索引页面上的文章数量 - 但是,我似乎设法破坏了我创建的任何 CATEGORY 页面。

例如,如果您转到http://www.invisiblejungle.com,则从“广播节目”类别中提取的“近期帖子”部分显示得很好。

但是,如果您单击导航栏中的 Radio Shows(这是一个类别),它会将侧边栏小部件扔到页面底部,并扭曲每篇单独的文章。

编辑:

我发现问题肯定出在 loop.php 中,当它检索帖子时。

<?php  
/**
 * The loop for displaying multiple posts (blog, search, categories, tags, etc).
 *
 * @package WordPress
 * @subpackage Debut
 * @since Debut 2.0
 *
 */
?>

    <?php   if( have_posts() ) : ?>

        <?php
        /**
         * Page Header
         *
         */
        locate_template( 'includes/page-header.php', true ); ?>

        <?php   while( have_posts() ) : the_post(); ?>

            <article id="post-<?php the_ID(); ?>" <?php post_class( 'entry' ) ?>>

                <?php 
                /**
                 * Entry Thumbnail
                 *
                 */
                locate_template( 'includes/entry-thumbnail.php', true, false ); ?>


                <?php
                /**
                 * Entry Header
                 *
                 */
                locate_template( 'includes/entry-header.php', true, false ); ?>


                <?php
                /**
                 * Entry Content/Summary
                 *
                 */
                if ( is_archive() || is_search() ) : // Check if this is an Archives and Search page ?>

                    <div class="entry-summary">

                        <?php the_excerpt(); ?>

                        <a class="more-link" href="<?php the_permalink() ?>" title="<?php c7s_the_title_attribute(); ?>"><?php _e( 'Read More &rarr;', 'framework' ); ?></a>

                    </div><!-- .entry-summary -->

                <?php else : // If not Archives or Search page ?>

                    <div class="entry-content">

                        <?php global $more; $more = 0; // Needed for more tag to work ?>

                        <?php the_content( __( 'Read More &rarr;', 'framework' ) ); // Show content ?>

                        <?php do_action( 'get_page_links' ); // Show page links (custom function to wp_link_pages() - functions/theme-helpers.php ?>

                    </div><!-- .entry-content -->

                <?php endif; // End Archive and Search page check ?>

            </article><!-- #post-## -->

            <?php 
            /**
             * Entry Comments
             *
             */
            comments_template( '', true ); ?>

        <?php endwhile; // end posts loop ?>
      <?php else : // If there are not any posts ?>

        <?php
        /**
         * Page Header
         *
         */
        locate_template( 'includes/page-header.php', true ); ?>


        <?php
        /**
         * Archives
         *
         */
        get_template_part( 'loop', 'archives' ); ?>


    <?php endif; // end loop ?>

        <?php
    /**
     * Pagination
     *
     */
    if ( $wp_query->max_num_pages > 1 ) : // Check for pages ?>

        <div id="nav-below" class="pagenavi">

            <?php if ( function_exists( 'wp_pagenavi' ) ) : // Check for WP Page Navi Plugin ?>

                <?php wp_pagenavi(); ?>

            <?php else : ?>

                <div class="nav-previous"><?php next_posts_link( '<span class="meta-nav">&larr;</span>' . __( ' Older posts', 'framework' ) ); ?></div>

                <div class="nav-next"><?php previous_posts_link( __( 'Newer posts ', 'framework' ) . '<span class="meta-nav">&rarr;</span>' ); ?></div>

            <?php endif; // End WP Page Navi plugin check ?>


        </div><!-- #nav-below -->

    <?php endif; // end page check ?>

</section><!-- #entry-container -->

【问题讨论】:

  • 你能列出你的主题文件夹中的文件吗?看来类别页面和搜索页面正在这样做。
  • 有几个: Comments (cmets.php) Footer (footer.php) theme-helpers.php theme-metabox.php theme-tinymce.php theme-widgets.php 主题函数(functions.php ) 标头 (header.php) home.php 公告.php archives.php entry-header.php entry-thumbnail.php page-header.php 主索引模板 (index.php) loop-archives.php loop-featured.php 循环-hero.php loop-singular.php loop.php options-announcement.php options-featured.php options-footer.php options-general.php options-hero.php options-instant-view.php options-logo-icons。 php选项-menus.php
  • options-plugins.php options-save-the-web.php options-social-media.php options-thank-you.php options-theme-styles.php options.php 页面模板(页面.php) 搜索表单 (searchform.php) sidebar-footer.php 边栏 (sidebar.php) 单篇文章 (single.php) 档案页面模板 (template-archives.php) 居中页面模板 (template-centered.php) 全宽页面模板 (template-full.php) 自定义帖子页面页面模板 (template-post-page.php) 抱歉,我在 cmets 中没有非常方便的方法来执行此操作...我将其发布在主文件。

标签: php wordpress categories


【解决方案1】:
<div id="main-container" role="main">

<section id="main">    

<section id="entry-container" role="contentinfo">////   


    <header class="entry page-header">

    ....
    ....
    ....            


    </ul><!-- #sidebar -->

</section><!-- #sidebar-container -->

</section><!-- #main -->////



    <div class="clearfix"><!-- nothing to see here --></div>

</div>

我在 //// 之后放置的行是修复 html 的内容。请从您的工作页面中发布 php,以便我进行比较。

【讨论】:

    【解决方案2】:

    问题可能出在您的archive.php 中。

    根据 Wordpress 模板层次结构,Wordpress 按这些文件的顺序查找您的类别页面:

     category-{slug}.php - If the category's slug were news, WordPress
     would look for category-news.php category-{id}.php - If the category's
     ID were 6, WordPress would look for category-6.php category.php
     archive.php 
     index.php
    

    http://codex.wordpress.org/Template_Hierarchy

    所以很可能您的错误位于该文件中。你可以做些什么来解决这个问题,就是进入一个运行良好的文件。比如你的page.php 并将其所有内容复制到archive.php。请务必先备份!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-13
      • 2018-08-18
      • 1970-01-01
      • 2013-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-31
      相关资源
      最近更新 更多