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


PHP adjacent_post_link函数代码示例

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


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

示例1: next_post_link

/**
 * Display next post link that is adjacent to the current post.
 *
 * @since 1.5.0
 *
 * @param string $format Optional. Link anchor format.
 * @param string $link Optional. Link permalink format.
 * @param bool $in_same_cat Optional. Whether link should be in same category.
 * @param string $excluded_categories Optional. Excluded categories IDs.
 */
function next_post_link($format = '%link »', $link = '%title', $in_same_cat = false, $excluded_categories = '')
{
    adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false);
}
开发者ID:vpatrinica,项目名称:jfdesign,代码行数:14,代码来源:link-template.php

示例2: adjacent_post_link

 /**
  * This function mimics the WordPress function adjacent_post_link()
  * because we cannot use that function properly.
  *
  * In the WordPress function, adjacent_post_link(), you are only allowed
  * to use 'category' for your taxonomy but this function adds a new parameter that 
  * allows you to designate which CPT-onomy you would like to use.
  *
  * @since 1.0.2
  * @uses $cpt_onomies_manager
  * @param string $format Link anchor format.
  * @param string $link Link permalink format.
  * @param bool $in_same_cpt_onomy Optional. Whether link should be in a same CPT-onomy.
  * @param array|string $excluded_term_ids Optional. Array or comma-separated list of excluded term IDs.
  * @param bool $previous Optional, default is true. Whether to display link to previous or next post.
  * @param string $cpt_onomy - name of the CPT-onomy for $in_same_cpt_onomy
  */
 function adjacent_post_link($format, $link, $in_same_cpt_onomy = false, $excluded_term_ids = '', $previous = true, $cpt_onomy = '')
 {
     global $cpt_onomies_manager;
     // If it's empty or not a valid CPT-onomy, then run the default WordPress function
     if (empty($cpt_onomy) || !$cpt_onomies_manager->is_registered_cpt_onomy($cpt_onomy)) {
         adjacent_post_link($format, $link, $in_same_cpt_onomy, $excluded_term_ids, $previous);
     } else {
         if ($previous && is_attachment()) {
             $post =& get_post($GLOBALS['post']->post_parent);
         } else {
             $post = $this->get_adjacent_post($in_same_cpt_onomy, $excluded_term_ids, $previous, $cpt_onomy);
         }
         if (!$post) {
             return;
         }
         $title = $post->post_title;
         if (empty($post->post_title)) {
             $title = $previous ? __('Previous Post', CPT_ONOMIES_TEXTDOMAIN) : __('Next Post', CPT_ONOMIES_TEXTDOMAIN);
         }
         $title = apply_filters('the_title', $title, $post->ID);
         $date = mysql2date(get_option('date_format'), $post->post_date);
         $rel = $previous ? 'prev' : 'next';
         $string = '<a href="' . get_permalink($post) . '" rel="' . $rel . '">';
         $link = str_replace('%title', $title, $link);
         $link = str_replace('%date', $date, $link);
         $link = $string . $link . '</a>';
         $format = str_replace('%link', $link, $format);
         $adjacent = $previous ? 'previous' : 'next';
         echo apply_filters("{$adjacent}_post_link", $format, $link);
     }
 }
开发者ID:aarongillett,项目名称:B22-151217,代码行数:48,代码来源:cpt-onomy.php


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