当前位置: 首页>>代码示例>>PHP>>正文


PHP get_boundary_post函数代码示例

本文整理汇总了PHP中get_boundary_post函数的典型用法代码示例。如果您正苦于以下问题:PHP get_boundary_post函数的具体用法?PHP get_boundary_post怎么用?PHP get_boundary_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_boundary_post函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_get_adjacent_post

 /**
  * @ticket 17807
  */
 public function test_get_adjacent_post()
 {
     // Need some sample posts to test adjacency
     $post_one = self::factory()->post->create_and_get(array('post_title' => 'First', 'post_date' => '2012-01-01 12:00:00'));
     $post_two = self::factory()->post->create_and_get(array('post_title' => 'Second', 'post_date' => '2012-02-01 12:00:00'));
     $post_three = self::factory()->post->create_and_get(array('post_title' => 'Third', 'post_date' => '2012-03-01 12:00:00'));
     $post_four = self::factory()->post->create_and_get(array('post_title' => 'Fourth', 'post_date' => '2012-04-01 12:00:00'));
     // Assign some terms
     wp_set_object_terms($post_one->ID, 'wordpress', 'category', false);
     wp_set_object_terms($post_three->ID, 'wordpress', 'category', false);
     wp_set_object_terms($post_two->ID, 'plugins', 'post_tag', false);
     wp_set_object_terms($post_four->ID, 'plugins', 'post_tag', false);
     // Test normal post adjacency
     $this->go_to(get_permalink($post_two->ID));
     $this->assertEquals($post_one, get_adjacent_post(false, '', true));
     $this->assertEquals($post_three, get_adjacent_post(false, '', false));
     $this->assertNotEquals($post_two, get_adjacent_post(false, '', true));
     $this->assertNotEquals($post_two, get_adjacent_post(false, '', false));
     // Test category adjacency
     $this->go_to(get_permalink($post_one->ID));
     $this->assertEquals('', get_adjacent_post(true, '', true, 'category'));
     $this->assertEquals($post_three, get_adjacent_post(true, '', false, 'category'));
     // Test tag adjacency
     $this->go_to(get_permalink($post_two->ID));
     $this->assertEquals('', get_adjacent_post(true, '', true, 'post_tag'));
     $this->assertEquals($post_four, get_adjacent_post(true, '', false, 'post_tag'));
     // Test normal boundary post
     $this->go_to(get_permalink($post_two->ID));
     $this->assertEquals(array($post_one), get_boundary_post(false, '', true));
     $this->assertEquals(array($post_four), get_boundary_post(false, '', false));
     // Test category boundary post
     $this->go_to(get_permalink($post_one->ID));
     $this->assertEquals(array($post_one), get_boundary_post(true, '', true, 'category'));
     $this->assertEquals(array($post_three), get_boundary_post(true, '', false, 'category'));
     // Test tag boundary post
     $this->go_to(get_permalink($post_two->ID));
     $this->assertEquals(array($post_two), get_boundary_post(true, '', true, 'post_tag'));
     $this->assertEquals(array($post_four), get_boundary_post(true, '', false, 'post_tag'));
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:42,代码来源:getAdjacentPost.php

示例2: get_boundary_post_rel_link

/**
 * Get boundary post relational link.
 *
 * Can either be start or end post relational link.
 *
 * @since 2.8.0
 * @deprecated 3.3.0
 *
 * @param string $title Optional. Link title format.
 * @param bool $in_same_cat Optional. Whether link should be in a same category.
 * @param string $excluded_categories Optional. Excluded categories IDs.
 * @param bool $start Optional, default is true. Whether to display link to first or last post.
 * @return string
 */
function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true)
{
    _deprecated_function(__FUNCTION__, '3.3');
    $posts = get_boundary_post($in_same_cat, $excluded_categories, $start);
    // If there is no post stop.
    if (empty($posts)) {
        return;
    }
    // Even though we limited get_posts to return only 1 item it still returns an array of objects.
    $post = $posts[0];
    if (empty($post->post_title)) {
        $post->post_title = $start ? __('First Post') : __('Last Post');
    }
    $date = mysql2date(get_option('date_format'), $post->post_date);
    $title = str_replace('%title', $post->post_title, $title);
    $title = str_replace('%date', $date, $title);
    $title = apply_filters('the_title', $title, $post->ID);
    $link = $start ? "<link rel='start' title='" : "<link rel='end' title='";
    $link .= esc_attr($title);
    $link .= "' href='" . get_permalink($post) . "' />\n";
    $boundary = $start ? 'start' : 'end';
    return apply_filters("{$boundary}_post_rel_link", $link);
}
开发者ID:rkglug,项目名称:WordPress,代码行数:37,代码来源:deprecated.php

示例3: next_post_link

</a></span>
              <?php 
        }
        ?>
              <?php 
        if (get_adjacent_post($in_same_cat = true, '', $previous = false)) {
            ?>
					  <span class="next"><?php 
            next_post_link('%link', 'Next: %title &rsaquo;', true);
            ?>
</span>
              <?php 
        } else {
            ?>
					  <?php 
            $first_post = array_pop(get_boundary_post($in_same_cat = true, '', $oldest = true));
            ?>
					  <span class="next"><a href="<?php 
            echo get_permalink($first_post);
            ?>
">First: <?php 
            echo $first_post->post_title;
            ?>
 &rsaquo;</a></span>
              <?php 
        }
        ?>
            </div>
            <?php 
    }
    ?>
开发者ID:renocollective,项目名称:informed-nv,代码行数:31,代码来源:single.php


注:本文中的get_boundary_post函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。