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


PHP get_previous_post函数代码示例

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


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

示例1: NextAndPreviousLinks

function NextAndPreviousLinks()
{
    global $wp_query;
    $previous_post = get_previous_post();
    $next_post = get_next_post();
    $prev_id = empty($previous_post) ? null : $previous_post->ID;
    $next_id = empty($next_post) ? null : $next_post->ID;
    ?>
  <?php 
    if (!empty($prev_id) && !empty($next_id)) {
        ?>
    <nav class="post-links post-links--both" role="navigation">
      <?php 
        Article_PreviewThumbnail($prev_id);
        ?>
      <?php 
        Article_PreviewThumbnail($next_id);
        ?>
    </nav>
  <?php 
    } elseif (!empty($prev_id)) {
        ?>
    <nav class="post-links post-links--single" role="navigation">
      <?php 
        Article_PreviewThumbnail($prev_id);
        ?>
    </nav>
  <?php 
    } elseif (!empty($next_id)) {
        ?>
    <nav class="post-links post-links--single" role="navigation">
      <?php 
        Article_PreviewThumbnail($next_id);
        ?>
    </nav>
  <?php 
    }
}
开发者ID:gios-asu,项目名称:bemmy-wordpress-theme,代码行数:38,代码来源:NextAndPreviousLinks.php

示例2: link_rel_prev_next

function link_rel_prev_next()
{
    // <link rel="home" title="Home" href="http://url/of/home/page" />
    $prev_url = '';
    $next_url = '';
    if (!is_singular()) {
        $prev_url = get_previous_posts_page_link();
        $next_url = get_next_posts_page_link();
        if (!empty($prev_url)) {
            printf('<link rel="prev" href="%s" />' . "\n", $prev_url);
        }
        if (!empty($next_url)) {
            printf('<link rel="next" href="%s" />' . "\n", $next_url);
        }
    } else {
        global $post;
        // $up_post = get_post($post->post_parent);
        //
        // $prev_post = get_previous_post();
        // if ( !empty( $prev_post->ID))
        //   printf( '<link rel="prev" title="%s" href="%s" />' . "\n", $prev_post->post_title , get_permalink($prev_post->ID) );
        //
        // $next_post = get_next_post();
        // if ( !empty($next_post->ID))
        //   printf( '<link rel="next" title="%s" href="%s" />' . "\n", $prev_post->post_title , get_permalink($next_post->ID) );
        safe_link_rel('next', get_post($post->parent));
        safe_link_rel('prev', get_previous_post());
        safe_link_rel('next', get_next_post());
    }
}
开发者ID:josephholsten,项目名称:Link-rel-prev-next,代码行数:30,代码来源:link_rel_prev_next.php

示例3: load_settings

 function load_settings()
 {
     $options = $this->get_wp_post_navigation_options();
     $navi = $options['nav_within_cat'] == "1" ? true : false;
     $next_post = get_next_post($navi);
     $pre_post = get_previous_post($navi);
     if ($options['navi_img'] != "1") {
         if ($options['is_custom'] != "1") {
             $pre_navigation = $pre_post->ID != "" ? '<a href="' . get_permalink($pre_post->ID) . '">' . $pre_post->post_title . '</a>' : '';
             $next_navigation = $next_post->ID != "" ? '<a href="' . get_permalink($next_post->ID) . '">' . $next_post->post_title . '</a>' : '';
         } else {
             $pre_navigation = $pre_post->ID != "" ? '<a href="' . get_permalink($pre_post->ID) . '">' . $options['custom_pre'] . '</a>' : '';
             $next_navigation = $next_post->ID != "" ? '<a href="' . get_permalink($next_post->ID) . '">' . $options['custom_next'] . '</a>' : '';
         }
     } else {
         $pre_navigation = $pre_post->ID != "" ? '<a href="' . get_permalink($pre_post->ID) . '"><img src="' . $options['pre_img_link'] . '" /></a>' : '';
         $next_navigation = $next_post->ID != "" ? '<a href="' . get_permalink($next_post->ID) . '"><img src="' . $options['next_img_link'] . '" /></a>' : '';
     }
     $img = $options['navi_img'] == "1" ? "-1" : '';
     $this->config["is_reversed"] = $options['is_reversed'];
     $this->config["hasImage"] = $img;
     $nex = $this->config["is_reversed"] == "1" ? $next_navigation : $pre_navigation;
     $pre = $this->config["is_reversed"] == "1" ? $pre_navigation : $next_navigation;
     $this->config["prePost"] = $pre;
     $this->config["nextPost"] = $nex;
     $this->config["is_active"] = $options['is_active'];
     $this->config["position"] = $options['position'];
 }
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:28,代码来源:wp-post-navigation.php

示例4: prev_next_post_link

function prev_next_post_link()
{
    $prev_post = get_previous_post();
    $next_post = get_next_post();
    ?>
  <div id="post_nav">
    <?php 
    if ($prev_post) {
        ?>
      <div id="prev_post">
        <?php 
        previous_post_link('%link', '&#8656;%title', false);
        ?>
      </div>
    <?php 
    }
    ?>
    <?php 
    if ($next_post) {
        ?>
      <div id="next_post">
        <?php 
        next_post_link('%link', '%title&#8658;', false);
        ?>
      </div>
    <?php 
    }
    ?>
  </div>
<?php 
}
开发者ID:kenyakodaira,项目名称:kenyanke,代码行数:31,代码来源:template-prev-next-link.php

示例5: beans_child_previous_text_post_navigation

function beans_child_previous_text_post_navigation()
{
    if ($post = get_previous_post()) {
        $text = $post->post_title;
    }
    return '<strong class="uk-display-block">Previous post </strong>' . $text;
}
开发者ID:ThemeButler,项目名称:tm-site,代码行数:7,代码来源:single.php

示例6: zp_get_portfolio_sidebar

function zp_get_portfolio_sidebar()
{
    global $post;
    // retrieve post meta values
    $button_label = get_post_meta($post->ID, 'button_label', true);
    $button_link = get_post_meta($post->ID, 'button_link', true);
    $date_label = get_post_meta($post->ID, 'date_label', true);
    $date_value = get_post_meta($post->ID, 'date_value', true);
    $client_label = get_post_meta($post->ID, 'client_label', true);
    $client_value = get_post_meta($post->ID, 'client_value', true);
    $category_label = get_post_meta($post->ID, 'category_label', true);
    $video_link = get_post_meta($post->ID, 'video_link', true);
    $output = '';
    if (have_posts()) {
        while (have_posts()) {
            the_post();
            $output .= '<div class="col-md-12 single_portfolio_sidebar">';
            if ($button_link) {
                $output .= '<div class="single_portfolio_section single_portfolio_button col-m-12"><a class="btn btn-hg btn-primary " href="' . $button_link . '">' . $button_label . '</a></div>';
            }
            $output .= '<div class="single_portfolio_section single_portfolio_content col-m-12">' . get_the_content() . '</div>';
            if ($date_value || $client_value || $category_label) {
                $output .= '<div class="single_portfolio_section single_portfolio_meta col-m-12">';
                if ($date_value) {
                    $output .= '<div class="meta_value date_meta"><span class="meta_label">' . $date_label . '</span>' . $date_value . '</div>';
                }
                if ($client_value) {
                    $output .= '<div class="meta_value client_meta"><span class="meta_label">' . $client_label . '</span>' . $client_value . '</div>';
                }
                // retrieve portfolio category
                if ($category_label) {
                    $output .= '<div class="meta_value category_meta"><span class="meta_label">' . $category_label . '</span>';
                    $categories = wp_get_post_terms($post->ID, 'portfolio_category');
                    foreach ($categories as $category) {
                        $output .= $category->name . ' ';
                    }
                    $output .= '</div>';
                }
                $output .= '</div>';
            }
            $output .= '<div class="single_portfolio_section single_portfolio_nav col-m-12">';
            $prev_post = get_previous_post();
            if (!empty($prev_post)) {
                $output .= '<div class="single_nav_prev"><a href="' . get_permalink($prev_post->ID) . '" class="btn btn-sm btn-primary">' . __('previous', 'start') . '</a></div>';
            }
            $next_post = get_next_post();
            if (!empty($next_post)) {
                $output .= '<div class="single_nav_next inline"><a href="' . get_permalink($next_post->ID) . '" class="btn btn-sm btn-primary">' . __('next', 'start') . '</a></div>';
            }
            $output .= '</div>';
            $output .= '</div>';
        }
    }
    genesis_structural_wrap('sidebar');
    do_action('genesis_before_sidebar_widget_area');
    echo $output;
    do_action('genesis_after_sidebar_widget_area');
    genesis_structural_wrap('sidebar', 'close');
}
开发者ID:sello-rex,项目名称:ased,代码行数:59,代码来源:single-portfolio.php

示例7: getSinglePost

 /**
  * Возвращает массив данных о записи
  * @return array|bool|null|\WP_Post
  */
 function getSinglePost()
 {
     global $post;
     $result = false;
     if (have_posts()) {
         the_post();
         $category = get_the_category($post->ID);
         if (is_array($category) && count($category) > 0) {
             $post->category = $category;
             // Получаем произвольные поля
             $post->fields = get_fields($post->ID);
             $post->fields['detail_image'] = isset($post->fields['detail_image']) && !empty($post->fields['detail_image']) ? $post->fields['detail_image'] : Config::DEFAULT_IMAGE_SRC;
             // Получаем текст поста
             $content = get_post_field('post_content', $post->ID);
             $post->contentParts = get_extended($content);
             // Метки
             $post->terms = wp_get_post_tags($post->ID);
             if (isset($post->fields['photos']) && is_array($post->fields['photos']) && count($post->fields['photos']) > 0) {
                 foreach ($post->fields['photos'] as &$photo) {
                     $photo->fields = get_fields($photo->ID);
                     $photo->terms = wp_get_post_tags($photo->ID);
                     $post->fields['detail_image'] = isset($post->fields['detail_image']) && !empty($post->fields['detail_image']) ? $post->fields['detail_image'] : Config::DEFAULT_IMAGE_SRC;
                 }
             }
             $result = $post;
             // Читайте далее
             $readMorePosts = array();
             // Получаем предыдущий пост для блока читайте далее
             $previousPost = get_previous_post(true);
             $isHavePosts = is_object($previousPost) ? true : false;
             $readMorePosts[] = $previousPost;
             // Получаем 2 последующих поста для блока читайте далее
             $query = new \WP_Query(array('posts_per_page' => 2, 'category_name' => $category[0]->slug, 'orderby' => 'post_date', 'order' => 'DESC', 'post_status' => 'publish', 'post__not_in' => array($post->ID), 'date_query' => array(array('after' => $post->post_date, 'inclusive' => true))));
             while ($query->have_posts()) {
                 $query->the_post();
                 $readMorePosts[] = $post;
             }
             wp_reset_postdata();
             $result->readMorePosts = array();
             if ($isHavePosts || count($readMorePosts) > 2) {
                 $numperReadMorePosts = 0;
                 foreach ($readMorePosts as &$post) {
                     if (is_object($post) && $numperReadMorePosts < 2) {
                         // Получаем прикрепленное изображение для поста в блоке Читайте далее
                         $post->fields = get_fields($post->ID);
                         // Получаем текст для поста в блоке Читайте далее
                         $content = get_post_field('post_content', $post->ID);
                         $post->contentParts = get_extended($content);
                         $post->terms = wp_get_post_tags($post->ID);
                         $post->permalink = get_permalink($post->ID);
                         $result->readMorePosts[] = $post;
                     }
                 }
             }
         }
     }
     return $result;
 }
开发者ID:Valeriya-Alekseeva,项目名称:ShowplaceUdmurtia,代码行数:62,代码来源:ContentHelper.php

示例8: filter_previous_post_link

function filter_previous_post_link($link)
{
    global $post;
    $post = get_post($post_id);
    $previous_post = get_previous_post();
    $title = $previous_post->post_title;
    $link = str_replace("rel=", 'class="previous" rel=', $link);
    return $link;
}
开发者ID:kamleshcropin,项目名称:Agency-Theme,代码行数:9,代码来源:utility-functions.php

示例9: singular_content_footer

/**
 * 個別ページ用のコンテンツフッターを表示
 */
function singular_content_footer($is_print = false)
{
    $html = "";
    //広告
    $html .= '<div class="ad-label lined">広告</div>';
    $html .= \getAdCode('rectangle');
    //次の記事
    $next = \get_next_post(true);
    if ($next) {
        $next_post = new LinkCard($next);
        $next_code = $next_post->getCode("article_footer_link", "next-post");
        $next_html = <<<EOD
<div class="link-card-container">
\t<h5>次の記事</h5>
\t\t{$next_code}
</div>
EOD;
    } else {
        $next_html = "";
    }
    //前の記事
    $prev = \get_previous_post(true);
    if ($prev) {
        $prev_post = new LinkCard($prev);
        $prev_code = $prev_post->getCode('article_footer_link', 'prev-post');
        $prev_html = <<<EOD
<div class="link-card-container">
\t<h5>前の記事</h5>
\t{$prev_code}
</div>
EOD;
    } else {
        $prev_html = "";
    }
    $nav = $next || $prev ? $next_html . $prev_html : "&nbsp;";
    $ad = '<div class="ad-label lined">広告</div>';
    $ad .= \getAdCode('scraper');
    $html .= <<<EOD
<footer class="content pure-g">
\t<div class="pure-u-1 pure-u-sm-3-4 pure-u-md-17-24 pure-u-lg-5-8">
\t\t<div class="content-footer">
\t\t\t{$nav}
\t\t</div>
\t</div>
\t<div class="pure-u-1 pure-u-sm-1-4 pure-u-md-7-24 pure-u-lg-3-8">
\t{$ad}
\t</div>
</footer>

EOD;
    if ($is_print) {
        echo $html;
    } else {
        return $html;
    }
}
开发者ID:Aquei,项目名称:purely,代码行数:59,代码来源:singular_content_footer.php

示例10: wptouch_theme_get_previous_post_link

function wptouch_theme_get_previous_post_link()
{
    $prev_post = get_previous_post();
    if ($prev_post) {
        $prev_post = get_previous_post(false);
        $prev_url = get_permalink($prev_post->ID);
        //		echo '<a href="#" rel="' . $prev_url . '" class="nav-back ajax-link">' . __( "Back", "wptouch-pro" ) . '</a>'; <- playing with ajax
        echo '<a href="' . $prev_url . '" class="nav-back ajax-link">' . __("Back", "wptouch-pro") . '</a>';
    }
}
开发者ID:macconsultinggroup,项目名称:WordPress,代码行数:10,代码来源:functions.php

示例11: eryn_post_nav

    /**
     * Display navigation to next/previous post when applicable.
     */
    function eryn_post_nav()
    {
        // Don't print empty markup if there's nowhere to navigate.
        $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
        $next = get_adjacent_post(false, '', false);
        if (!$next && !$previous) {
            return;
        }
        ?>
	<nav class="navigation post-navigation" role="navigation">
		<h1 class="screen-reader-text"><?php 
        _e('Post navigation', 'eryn');
        ?>
</h1>
		<div class="nav-links">
        <?php 
        $next_post = get_next_post();
        $prev_post = get_previous_post();
        if (!empty($prev_post)) {
            ?>
            	<div class="nav-previous">
                	<a href="<?php 
            echo get_permalink($prev_post->ID);
            ?>
">
                        <span class="meta-nav">&larr;</span>
                        <?php 
            _e('Previous Post', 'eryn');
            ?>
                    </a>
                </div>
			<?php 
        }
        ?>
			
			<?php 
        if (!empty($next_post)) {
            ?>
            	<div class="nav-next">
					<a href="<?php 
            echo get_permalink($next_post->ID);
            ?>
"><?php 
            _e('Next Post', 'eryn');
            ?>
                    	<span class="meta-nav">&rarr;</span>
                    </a>
                </div>
			<?php 
        }
        ?>
		</div><!-- .nav-links -->
	</nav><!-- .navigation -->
	<?php 
    }
开发者ID:COfrost,项目名称:www.example.dev,代码行数:58,代码来源:template-tags.php

示例12: tls_latest_edition_page_json_api_encode

/**
 * Latest Edition Page Template JSON API Response Modifications
 *
 * @param $response     The JSON API Response Object
 *
 * @return $response    Update JSON API Response Object
 */
function tls_latest_edition_page_json_api_encode($response)
{
    if (isset($response['page_template_slug']) && $response['page_template_slug'] == "template-latest-edition.php" || isset($response['post']) && $response['post']->type == 'tls_editions') {
        if (isset($response['page_template_slug']) && $response['page_template_slug'] == "template-latest-edition.php") {
            $latest_edition = new WP_Query(array('post_type' => 'tls_editions', 'post_status' => 'publish', 'posts_per_page' => 1, 'orderby ' => 'date'));
            wp_reset_query();
        } else {
            if (isset($response['post']) && $response['post']->type == 'tls_editions') {
                $latest_edition = new WP_Query(array('p' => $response['post']->id, 'post_type' => 'tls_editions', 'post_status' => 'publish', 'posts_per_page' => 1, 'orderby ' => 'date'));
                wp_reset_query();
            }
        }
        $latest_edition = $latest_edition->posts[0];
        global $post;
        $oldGlobal = $post;
        $post = get_post($latest_edition->ID);
        $response['latest_edition'] = array('id' => $latest_edition->ID, 'title' => get_the_title($latest_edition->ID), 'url' => get_permalink($latest_edition->ID));
        if (get_previous_post()) {
            $previousPost = get_previous_post();
            $response['latest_edition']['previous_post_info'] = array('previous' => $previousPost, 'id' => $previousPost->ID, 'title' => get_the_title($previousPost->ID), 'url' => get_permalink($previousPost->ID));
        }
        if (get_next_post()) {
            $nextPost = get_next_post();
            $response['latest_edition']['next_post_info'] = array('next' => $nextPost, 'id' => $nextPost->ID, 'title' => get_the_title($nextPost->ID), 'url' => get_permalink($nextPost->ID));
        }
        $latest_edition_articles = get_fields($latest_edition->ID);
        $response['latest_edition']['content']['featured'] = array('issue_no' => $latest_edition_articles['edition_number'], 'image_url' => $latest_edition_articles['feautured_image']['url']);
        $response['latest_edition']['content']['public']['title'] = __('Public content', 'tls');
        $public_articles = get_field('public_articles', $latest_edition->ID);
        foreach ($public_articles as $public_article) {
            $section = wp_get_post_terms($public_article->ID, 'article_section');
            $postAuthor = get_field('field_54e4d3b1b0094', $public_article->ID);
            $response['latest_edition']['content']['public']['articles'][$public_article->post_name] = array('id' => $public_article->ID, 'author' => $postAuthor, 'title' => get_the_title($public_article->ID), 'section' => array('name' => $section[0]->name, 'link' => get_term_link($section[0]->term_id, $section[0]->taxonomy)), 'url' => get_permalink($public_article->ID));
        }
        $response['latest_edition']['content']['regulars']['title'] = __('Regular Features', 'tls');
        $regular_articles = get_field('edition_regular_articles', $latest_edition->ID);
        foreach ($regular_articles as $regular_article) {
            $postAuthor = get_field('field_54e4d3b1b0094', $regular_article->ID);
            $section = wp_get_post_terms($regular_article->ID, 'article_section');
            $article_section = wp_get_post_terms($regular_article->ID, 'article_visibility');
            $response['latest_edition']['content']['regulars']['articles'][$regular_article->post_name] = array('type' => 'article', 'id' => $regular_article->ID, 'author' => $postAuthor, 'title' => get_the_title($regular_article->ID), 'section' => array('name' => $section[0]->name, 'link' => get_term_link($section[0]->term_id, $section[0]->taxonomy)), 'taxonomy_article_visibility' => $article_section, 'url' => get_permalink($regular_article->ID));
        }
        $response['latest_edition']['content']['subscribers']['title'] = __('Subscriber Exclusive');
        $subscriber_only_articles = get_field('subscriber_only_articles', $latest_edition->ID);
        foreach ($subscriber_only_articles as $subscriber_only_article) {
            $section = wp_get_post_terms($subscriber_only_article->ID, 'article_section');
            $postAuthor = get_field('field_54e4d3b1b0094', $subscriber_only_article->ID);
            $response['latest_edition']['content']['subscribers']['articles'][$section[0]->name]['section']->name = $section[0]->name;
            $response['latest_edition']['content']['subscribers']['articles'][$section[0]->name]['section']->link = get_term_link($section[0]->term_id, $section[0]->taxonomy);
            $response['latest_edition']['content']['subscribers']['articles'][$section[0]->name]['posts'][$subscriber_only_article->post_name] = array('id' => $subscriber_only_article->ID, 'author' => $postAuthor, 'title' => get_the_title($subscriber_only_article->ID), 'section' => array('name' => $section[0]->name, 'link' => get_term_link($section[0]->term_id, $section[0]->taxonomy)), 'url' => get_permalink($subscriber_only_article->ID));
        }
    }
    return $response;
}
开发者ID:dannyoz,项目名称:tls,代码行数:61,代码来源:tls_latest_edition_page_json_api_encode.php

示例13: previousPortfolioLink

function previousPortfolioLink()
{
    if (get_previous_post()) {
        previous_post_link('%link', getPostLinkIcon('left'));
    } else {
        $args = array('post_type' => 'portfolio', 'posts_per_page' => '1', 'order' => 'DESC');
        $first = new WP_Query($args);
        $first->the_post();
        echo '<a rel="prev" href="' . get_permalink() . '">' . getPostLinkIcon('left') . '</a>';
        wp_reset_query();
    }
}
开发者ID:steveMQ,项目名称:Hairpin,代码行数:12,代码来源:portfolio-navigation.php

示例14: add_title_to_previous_post_link

function add_title_to_previous_post_link($link)
{
    global $post;
    $post = get_post($post->ID);
    $previous_post = get_previous_post();
    if ($previous_post) {
        $title = $previous_post->post_title;
    } else {
        $title = '';
    }
    $link = str_replace("rel=", " title='" . $title . "' rel=", $link);
    return $link;
}
开发者ID:gigikir,项目名称:adebe,代码行数:13,代码来源:_social_ktz.php

示例15: render

 public function render()
 {
     $this->entries = array();
     if (is_attachment()) {
     } elseif (is_single()) {
         $this->entries = array('previous' => get_previous_post(), 'next' => get_next_post());
         //        } elseif (is_archive() || is_search()) {
     } else {
         $this->type = 'numerical';
         $this->get_pagenav_num();
     }
     return $this->entries;
 }
开发者ID:e-picas,项目名称:wp-basic-bootstrap,代码行数:13,代码来源:WP_Basic_Bootstrap_Pagination.php


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