Where is Number of Posts Set?

时间:2016-02-08 作者:Michael Musgrove

我希望有人能帮我解决这个看似简单的问题。

这是我得到的一个自定义主题,简单地更改设置菜单中显示的帖子数量是无效的(设置为10)。但我不知道博客页面上显示的帖子摘录数量是在哪里设置的。目前是一个,底部有一个分页链接,但我正在尝试将其扩展到5。

页面为:https://community.sum180.com/blog/模板为:

<?php global $post, $wp_query, $blog_query, $shortcode_values, $theLayout; ?>


<section class="content-post-list">
    <ol class="posts-list hfeed">

    <?php
    if (!$blog_query) $blog_query = $wp_query;
    $blogOptions = ($shortcode_values) ? $shortcode_values : $theLayout[\'blog\'];

    while( $blog_query->have_posts() ) : $blog_query->the_post();

        // style and layout info
        $postClass = array();

        // images enabled?
        if ($blogOptions[\'blog_featured_images\']) {

            // class
            $postClass[] = \'\'; //\'style-image-left\';

            // get thumbnail image
            $thumb = get_post_thumbnail_id();

            // image sizes
            $imageW = $blogOptions[\'image\'][\'width\'];
            $imageH = $blogOptions[\'image\'][\'height\'];

            // crop image (default = true)
            $imageCrop = ( $imageW === 0 || $imageH === 0 ) ? false : true; // Setting to FALSE is useful when setting one value so other adjusts automatically

            // get resized image
            // this will return the resized $thumb or placeholder if enabled and no $thumb
            $image = vt_resize( $thumb, \'\', $imageW, $imageH, $imageCrop );

                // If media field is populated use lightbox for image/video on click
                $popup_link = \'\';
                if (get_meta(\'media_url\')) {
                    $popup_link = \'<a href="\'. get_meta(\'media_url\') .\'" class="popup" title="\'. get_meta(\'media_title\') .\'">\';
                }
        }

        if (!$image[\'url\']) {
            // no imge
            $postClass[] = \'noImage\';
        }

        ?>

        <li class="post-item clearfix">
            <article id="post-<?php the_ID(); ?>" <?php post_class($postClass); ?>>
                <div class="item-container">

                    <?php if ($image[\'url\']) : ?>
                    <div class="the-post-image">
                        <?php
                        if ($popup_link) :
                            echo $popup_link;
                        else : ?>
                            <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php printf( esc_attr__( \'Permalink to %s\', THEME_NAME ), the_title_attribute( \'echo=0\' ) ); ?>">
                        <?php endif; ?>
                            <figure>
                                <img src="<?php echo $image[\'url\']; ?>" width="<?php echo $image[\'width\']; ?>" height="<?php echo $image[\'height\']; ?>" />
                            </figure>
                        </a>
                    </div>
                    <?php endif; ?>

                    <div class="the-post-content">
                        <header class="entry-header">

                            <?php
                            // Author avatar
                            if ($blogOptions[\'author_avatar\']) :
                                ?>
                                <div class="author-avatar">
                                    <a href="<?php echo get_author_posts_url(get_the_author_meta(\'ID\')); ?>"><?php echo get_avatar(  get_the_author_meta(\'ID\'), 35, \'\', get_the_author_meta(\'display_name\')); ?></a>
                                </div>
                                <?php
                            endif; ?>

                            <!-- Title / Page Headline -->
                            <h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php printf( esc_attr__( \'Permalink to %s\', THEME_NAME ), the_title_attribute( \'echo=0\' ) ); ?>"><?php the_title(); ?></a></h2>

                            <?php if ($blogOptions[\'author_name\'] || $blogOptions[\'post_date\'] || $blogOptions[\'comments_link\'] || $blogOptions[\'category_list\']) : ?>
                            <div class="post-header-info clearfix" <?php if ( !$blogOptions[\'author_avatar\'] ) : echo \'style="margin-left: 0;"\'; endif; ?>>
                                <?php
                                // Author name
                                if ($blogOptions[\'author_name\']) :
                                    ?>
                                    <address class="vcard author">
                                        <?php _e( \'by \', THEME_NAME ) . the_author_posts_link(); ?>
                                    </address>
                                <?php
                                endif;
                                // Comments link
                                if ($blogOptions[\'comments_link\']) :
                                    // comments link ?>
                                    <span class="comments-link"><?php comments_popup_link( __( \'Comment\', THEME_NAME ), __( \'1\', THEME_NAME ), __( \'%\', THEME_NAME ), \'\', \'\' ); ?></span>
                                    <?php
                                endif;
                                // Category list
                                if ($blogOptions[\'category_list\']) :
                                    if ( count( get_the_category() ) ) :
                                        ?>
                                        <div class="cat-links">
                                            <?php
                                            // seperator
                                            if ($blogOptions[\'post_date\']) { echo \' <span class="meta-sep">|</span> \'; }
                                            //printf( __( \'<span class="%1$s">Posted in</span> %2$s\', THEME_NAME ), \'entry-utility-prep entry-utility-prep-cat-links\', get_the_category_list( \', \' ) );
                                            echo get_the_category_list( \', \' );
                                            ?>
                                        </div>
                                        <?php
                                    endif;
                                endif;
                                // Date Published
                                if ($blogOptions[\'post_date\']) :
                                    ?>
                                    <abbr class="published" title="<?php the_time(\'c\'); ?>"><span class="entry-date"><?php the_time(get_option(\'date_format\')); ?></span></abbr>
                                    <?php
                                    //if ($blogOptions[\'comments_link\']) { echo \' <span class="meta-sep">|</span> \'; }  // seperator
                                endif;
                                ?>
                            </div>
                            <?php endif; ?>

                        </header>

                        <!-- Content -->
                        <div class="entry-content">
                            <?php
                                // Post content/excerpt
                                if ($blogOptions[\'use_excerpt\']) {
                                    if ($blogOptions[\'excerpt_length\'] != \'-1\')  {
                                        echo customExcerpt(get_the_excerpt(), $blogOptions[\'excerpt_length\']);
                                    }
                                } else {
                                    // set $more to 0 or WP will ignore the <!--more--> tags if not on the home page
                                    global $more;
                                    $more = 0;
                                    the_content( __( \'Continue reading <span class="meta-nav">&rarr;</span>\', THEME_NAME ) );
                                }
                                // Read more link
                                if ($blogOptions[\'read_more\'] && $blogOptions[\'read_more\'] != "-1") {
                                    $readMore = prep_content($blogOptions[\'read_more\'], 0, 1);
                                    echo \'<div class="read-more"><a href="\'. get_permalink() .\'" title="\'. $readMore .\'" class="read-more-link">\'. $readMore .\'</a></div>\';
                                }
                            ?>
                        </div><!-- END .entry-content -->

                        <!-- Post Footer -->
                        <footer class="post-footer-info">
                            <?php
                            // tag list
                            if ($blogOptions[\'tag_list\']) :
                                $tags_list = get_the_tag_list( \'\', \', \' );
                                if ( $tags_list ):  ?>
                                <div class="tag-links">
                                    <?php printf( __( \'<span class="%1$s">Tagged</span> %2$s\', THEME_NAME ), \'entry-utility-prep entry-utility-prep-tag-links\', $tags_list ); ?>
                                </div>
                                <?php
                                endif;
                            endif; ?>
                        </footer><!-- END .post-footer-info -->
                    </div>

                </div>
            </article>
        </li>

        <?php endwhile; ?>

    </ol>
</section>


<?php

// show paging  (< 1 3 4 >)
if ($blogOptions[\'paging\']) get_pagination($blog_query);

?>

2 个回复
SO网友:Will

看起来像是http://para.llel.us/support/ 主题例如,您可以从那里开始创建文档,它们可能在管理中有一个自定义的“主题选项”页面。

除此之外,假设您可以在代码中进行设置(这可能会否定管理员中未来的任何设置),您首先需要找出$blog_query 正在定义。你可以从functions.php 但如果不知道主题,很难说。

找到后,请更新其posts_per_page 将值添加到所需的值,如果不存在,则手动添加。

SO网友:idpokute

使用以下代码:

query_posts(\'posts_per_page=5\');
$blogOptions = ($shortcode_values) ? $shortcode_values : $theLayout[\'blog\'];

相关推荐

add all blog posts to folder

我想将所有博客帖子添加到/blogs/post name类型结构中。我可以通过permalinks设置执行此操作:/blogs/%postname%/但这也会影响自定义帖子类型,导致/blogs/custom-post-type/the-custom-post-type-name如何将所有帖子添加到blogs文件夹中,而不将所有自定义帖子类型添加到blogs文件夹中?