简体   繁体   English

侧边栏小部件在类别页面上未对齐

[英]Sidebar Widget Misaligned on Category Pages

I'm re-posting the same problem, but I'm better defining the issues. 我要重新发布相同的问题,但最好定义这些问题。

Basically, I was trying to limit the number of articles that appeared on my index page - however, it seems that I managed to break any CATEGORY page that I create. 基本上,我试图限制出现在索引页面上的文章数量-但是,看来我设法破坏了我创建的任何CATEGORY页面。

For example, if you go to http://www.invisiblejungle.com , the "Recent Posts" section that pulls from the category "Radio Shows" appears just fine. 例如,如果您访问http://www.invisiblejungle.com ,那么从“电台节目”类别中拉出的“最新帖子”部分就很好了。

However, if you click Radio Shows in the navigation bar, which is a category, it throws the sidebar widget to the bottom of the page, and distorts each of the individual articles. 但是,如果单击导航栏中的“广播节目”(属于一个类别),则会将侧边栏小部件扔到页面底部,并使每个单独的文章变形。

EDIT: 编辑:

I've discovered that the issue is definitely in loop.php when it retrieves the posts. 我发现问题在检索帖子时肯定在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 -->
<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>

The lines I put //// after are what fixes the html. 我放在////之后的行是修复html的原因。 Please post the php from one of your working pages so I can compare. 请从您的工作页面之一发布php,以便我进行比较。

The problem is probably going to be in your archive.php. 问题可能出在您的archive.php中。

According to the Wordpress Template Hierarchy, Wordpress looks in order of these files to use for your category pages: 根据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 http://codex.wordpress.org/Template_Hierarchy

So most likely your error is located in that file. 因此,您的错误很可能位于该文件中。 What you could do to fix this though, is to going into a file that is working very well. 但是,您可以采取的措施来修复运行良好的文件。 Such as your page.php and copy all its contents into archive.php . 例如您的page.php并将其所有内容复制到archive.php Be sure to backup first! 请务必先备份!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM