Php 查询高级自定义字段;要为结果分页吗

Php 查询高级自定义字段;要为结果分页吗,php,wordpress,pagination,advanced-custom-fields,Php,Wordpress,Pagination,Advanced Custom Fields,不确定这是否特别适用于高级自定义字段,但我会保持简短。我对PHP比较陌生,想知道完成这项任务的最佳方法此外,这是一个WordPress(4.1.1)环境 我正在发送一个查询,查询所有具有关联类别类型的帖子类型,以便拉入并显示。如果查询可以找到帖子,它将生成一个 此页面使用的模板(news.php)包含以下内容: <?php /* Template Name: News */ ?> <?php get_header(); ?> <main id="p

不确定这是否特别适用于高级自定义字段,但我会保持简短。我对PHP比较陌生,想知道完成这项任务的最佳方法此外,这是一个WordPress(4.1.1)环境

我正在发送一个查询,查询所有具有关联类别类型的帖子类型,以便拉入并显示。如果查询可以找到帖子,它将生成一个

此页面使用的模板(news.php)包含以下内容:

<?php /* Template Name: News */ ?>
<?php get_header(); ?>

        <main id="primary" class="content-area">
          <div class="jumbotron">
            <div class="row">
              <div class="intro">
                <p><?php the_field('news_heading') ?></p>
              </div>
            </div>
          </div>
          <div class="news">
            <div class="row news-articles">
              <div class="column-wrapper">
                <div class="small-4 columns news-left-column">
                  <div class="select-dropdown">
                    <button href="#" data-dropdown="dropdown-items" aria-controls="dropdown-items" aria-expanded="false" class="dropdown">Select a news category</button>
                    <ul id="dropdown-items" data-dropdown-content class="f-dropdown" aria-hidden="true" tabindex="-1">
                      <?php $args = array(
                        'exclude'            => '',
                        'title_li'           => __( '' ),
                        'show_option_none'   => __( '<li><a href="#primary">No categories</a></li>' ),
                        'taxonomy'           => 'category',
                        'child_of'           => 2,
                        'current_category'   => 0
                      ); ?>
                      <?php wp_list_categories($args); ?>
                      <li class="cat-item cat-item-all-news"><a href="/news" alt="View all News" title="View all News">All News</a>
                    </ul>
                  </div>
                  <div class="news-block">
                    <span class="news-block-heading">Email Newsletters</span>
                    <div class="news-inner-block">
<?php if( have_rows('newsletters_list') ): ?>
  <?php while( have_rows('newsletters_list') ): the_row(); ?>
                      <span class="year"><?php the_sub_field('newsletter_year'); ?></span>
    <?php if( have_rows('newsletter_resource') ): ?>
                      <ul>
      <?php while( have_rows('newsletter_resource') ): the_row(); ?>
                        <li><a href="<?php the_sub_field('newsletter_url'); ?>" target="_blank"><?php the_sub_field('newsletter_title'); ?></a></li>
      <?php endwhile; ?>
                      </ul>
    <?php endif; ?>
  <?php endwhile; ?>
<?php endif; ?>
                    </div>
                  </div>
                </div>
                <div class="small-8 columns news-right-column">
<?php query_posts( 'post_type=post&cat=' ); ?>

  <?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>
                  <article class="large-6 columns ui-article-block">
                    <h3><?php echo get_the_date( 'd M Y' ); ?></h3>
                    <hr/>
                    <h2><?php foreach((get_the_category()) as $category) { echo $category->cat_name . ' '; } ?></h2>
                    <h1><?php the_title(); ?></h1>
                    <p>
      <?php
        $content = get_the_content();
        $content = strip_tags($content);
        echo substr($content, 0, 175) . "..."; // set a character cut-off at 175 characters
      ?>
                    </p>
                    <a href="<?php the_permalink(); ?>" alt="Read more about the article: <?php the_title_attribute(); ?>" title="Read more about the article: <?php the_title_attribute(); ?>" class="button postfix">Read More</a>
                  </article>
    <?php endwhile; ?>
  <?php else : ?>
                  <div class="large-8 columns">
                    <p class="lead">Well this is embarrassing. There are currently no news articles.</p>
                  </div>
  <?php endif; ?>
<?php wp_reset_query(); ?>
                </div>
              </div>
            </div>
          </div>
        </main>
<?php get_footer(); ?>

选择新闻类别 电子邮件通讯

这太尴尬了。目前没有新闻报道

需要明确的是,这不是一个问题,更重要的是,更多有经验的开发人员要求如何利用高级自定义字段元素来完成任务(如果这很重要的话)

任何帮助都将不胜感激

编辑

本次编辑是在OP对问题性质进行澄清之后进行的


,解释如何在初级阶段处理帖子中的数字导航

谢谢你的回复!这似乎截断了我的结果,但我仍然想知道是否有人对构建分页有建议?我们需要它显示数字,而不是标准的(上一篇文章/下一篇文章)WordPress默认分页。有什么建议吗?我已经添加了一个很好的资源,也希望其他人也能参与进来。谢谢你将我链接到这个资源Jude。我能够构建分页,但我注意到两个bug。我应该用我发现的错误更新这篇文章,还是我应该创建一个新问题?一个新问题是最好的。。我来看看,我在你建议的链接中,提出了一个新的问题,与我使用开箱即用的方法所做的发现有关。请检查这里的问题:当你有时间的时候,谢谢!