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


PHP previous_post_link函数代码示例

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


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

示例1: dswoddil_post_nav

    /**
     * Display navigation to next/previous post when applicable.
     *
     * @since DSW oddil 1.0
     */
    function dswoddil_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', 'dswoddil');
        ?>
</h1>
		<div class="nav-links">
			<?php 
        if (is_attachment()) {
            previous_post_link('%link', __('<span class="meta-nav">Published In</span>%title', 'dswoddil'));
        } else {
            previous_post_link('%link', __('<span class="meta-nav">Previous Post</span>%title', 'dswoddil'));
            next_post_link('%link', __('<span class="meta-nav">Next Post</span>%title', 'dswoddil'));
        }
        ?>
		</div><!-- .nav-links -->
	</nav><!-- .navigation -->
	<?php 
    }
开发者ID:kalich5,项目名称:dsw-oddil,代码行数:32,代码来源:template-tags.php

示例2: digistarter_post_nav

    /**
     * Display navigation to next/previous post when applicable.
     *
     * @return void
     */
    function digistarter_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">
		<h3 class="screen-reader-text">
		<?php 
        __('Post navigation', TRANSLATED_TEXT_DOMAIN);
        ?>
		</h3>
		<div class="nav-links">

			<?php 
        previous_post_link('%link', wp_kses(_x('<span class="meta-nav prev">&larr;</span> %title', 'Previous post link', TRANSLATED_TEXT_DOMAIN), array('span' => array('class' => array()))));
        ?>
			<?php 
        next_post_link('%link', wp_kses(_x('%title <span class="meta-nav next">&rarr;</span>', 'Next post link', TRANSLATED_TEXT_DOMAIN), array('span' => array('class' => array()))));
        ?>


		</div><!-- .nav-links -->
	</nav><!-- .navigation -->
	<?php 
    }
开发者ID:ahmadawais,项目名称:Moxie-Lean,代码行数:34,代码来源:template-tags.php

示例3: sf_display_nav

function sf_display_nav($navstyle = "nextprev", $class = "navigation")
{
    if (is_single()) {
        echo '<div class="' . $class . '"> <!-- BEGIN .' . $class . ' -->';
        echo '<div class="left">';
        previous_post_link();
        echo '</div>';
        echo '<div class="right">';
        next_post_link();
        echo '</div>';
        echo '</div> <!-- END .' . $class . ' -->';
    } else {
        $_SERVER['REQUEST_URI'] = preg_replace("/(.*?).php(.*?)&(.*?)&(.*?)&_=/", "\$2\$3", $_SERVER['REQUEST_URI']);
        echo '<div class="' . $class . '"> <!-- BEGIN .' . $class . ' -->';
        if ($navstyle == "nextprev") {
            echo '<div class="left">';
            next_posts_link('&laquo; Older Entries');
            echo '</div>';
            echo '<div class="right">';
            previous_posts_link('Newer Entries &raquo;');
            echo '</div>';
        } elseif ($navstyle == "numbar") {
            sf_corenav();
        }
        echo '</div> <!-- END .' . $class . ' -->';
    }
}
开发者ID:ksolomon,项目名称:Solo-Frame,代码行数:27,代码来源:library.php

示例4: the_post_navigation

    /**
     * Display navigation to next/previous post when applicable.
     *
     * @todo Remove this function when WordPress 4.3 is released.
     */
    function the_post_navigation()
    {
        // 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">
            <h2 class="screen-reader-text"><?php 
        _e('Post navigation', 'ncssm_sg');
        ?>
</h2>

            <div class="nav-links">
                <?php 
        previous_post_link('<div class="nav-previous">%link</div>', '%title');
        next_post_link('<div class="nav-next">%link</div>', '%title');
        ?>
            </div>
            <!-- .nav-links -->
        </nav><!-- .navigation -->
        <?php 
    }
开发者ID:ajspencer,项目名称:NCSSM-SG-WordPress,代码行数:30,代码来源:template-tags.php

示例5: my_simone_post_nav

    /**
     * Display navigation to next/previous post when applicable.
     *
     * @return void
     */
    function my_simone_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">
    <div class="post-nav-box clear">
        <h1 class="screen-reader-text"><?php 
        _e('Post navigation', 'my-simone');
        ?>
</h1>
        <div class="nav-links">
            <?php 
        previous_post_link('<div class="nav-previous"><div class="nav-indicator">' . _x('Previous Post:', 'Previous post', 'my-simone') . '</div><h1>%link</h1></div>', '%title');
        next_post_link('<div class="nav-next"><div class="nav-indicator">' . _x('Next Post:', 'Next post', 'my-simone') . '</div><h1>%link</h1></div>', '%title');
        ?>
        </div><!-- .nav-links -->
    </div><!-- .post-nav-box -->
</nav><!-- .navigation -->

			
	<?php 
    }
开发者ID:sintija,项目名称:wordpress_backup,代码行数:32,代码来源:template-tags.php

示例6: writ_post_nav

    /**
     * Display navigation to next/previous post when applicable.
     *
     * @return void
     */
    function writ_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', 'writ');
        ?>
</h1>
		<div class="nav-links">

			<?php 
        previous_post_link('<div class="nav-previous">%link</div>', '<div class="arrow">' . _x('&larr;', 'Previous post link', 'writ') . '</div><div class="link">%title</div>');
        ?>
			<?php 
        next_post_link('<div class="nav-next">%link</div>', '<div class="arrow">' . _x('&rarr;', 'Next post link', 'writ') . '</div><div class="link">%title</div>');
        ?>

		</div><!-- .nav-links -->
	</nav><!-- .navigation -->
	<?php 
    }
开发者ID:partisan-collective,项目名称:partisan,代码行数:32,代码来源:template-tags.php

示例7: wpsp_the_post_navigation

    /**
     * Display navigation to next/previous post when applicable.
     *
     * @todo Remove this function when WordPress 4.3 is released.
     */
    function wpsp_the_post_navigation()
    {
        // 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);
        /*$post_category_ids = wp_get_post_categories( get_the_ID(), array('fields' => 'ids') );
        	$category_ids = array();
        	foreach ( $post_category_ids as $cat ) {
        		$category = get_category( $cat );
        		array_push( $category_ids, $category->category_parent );
        	}
        	print_r( $category_ids );*/
        if (!$next && !$previous) {
            return;
        }
        ?>
	<nav class="navigation post-navigation" role="navigation">
	    <div class="post-nav-box clearfix">
	        <h1 class="screen-reader-text"><?php 
        _e('Post navigation', 'klahan9');
        ?>
</h1>
	        <div class="nav-links">
	            <?php 
        previous_post_link('<div class="nav-previous"><div class="nav-indicator">' . _x('Previous Post:', 'Previous post', 'klahan9') . '</div><h1>%link</h1></div>', '%title', true);
        next_post_link('<div class="nav-next"><div class="nav-indicator">' . _x('Next Post:', 'Next post', 'klahan9') . '</div><h1>%link</h1></div>', '%title', true);
        ?>
	        </div><!-- .nav-links -->
	    </div><!-- .post-nav-box -->
	</nav><!-- .navigation -->
	<?php 
    }
开发者ID:sptheme,项目名称:klahan9,代码行数:37,代码来源:theme-functions.php

示例8: sbg_custom_post_nav

function sbg_custom_post_nav()
{
    echo '<div class="prev-next-post-links">';
    previous_post_link('<div class="previous-post-link">&laquo; %link</div>', '<strong>%title</strong>');
    next_post_link('<div class="next-post-link">%link &raquo;</div>', '<strong>%title</strong>');
    echo '</div>';
}
开发者ID:Friends-School-Atlanta,项目名称:Deployable-WordPress,代码行数:7,代码来源:single-staff-member.php

示例9: 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

示例10: oceanic_post_nav

    /**
     * Display navigation to next/previous post when applicable.
     */
    function oceanic_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', 'oceanic');
        ?>
</h1>
		<div class="nav-links">
			<?php 
        $slider_cats = get_theme_mod('oceanic-slider-cats', false);
        $slider_cat_ids = array();
        if ($slider_cats) {
            $slider_cats = explode(',', esc_html($slider_cats));
            for ($i = 0; $i < count($slider_cats); ++$i) {
                $cat_id = get_cat_ID($slider_cats[$i]);
                if ($cat_id > 0) {
                    $slider_cat_ids[$i] = $cat_id;
                }
            }
        }
        previous_post_link('<div class="nav-previous">%link</div>', _x('<span class="meta-nav">&larr;</span>&nbsp;%title', 'Previous post link', 'oceanic'), false, $slider_cat_ids);
        next_post_link('<div class="nav-next">%link</div>', _x('%title&nbsp;<span class="meta-nav">&rarr;</span>', 'Next post link', 'oceanic'), false, $slider_cat_ids);
        ?>
		</div><!-- .nav-links -->
	</nav><!-- .navigation -->
	<?php 
    }
开发者ID:neetudave,项目名称:heartfulness-uk,代码行数:37,代码来源:template-tags.php

示例11: twentyfifteen_post_nav

    /**
     * Display navigation to next/previous post when applicable.
     *
     * @since Twenty Fifteen 1.0
     */
    function twentyfifteen_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 || is_attachment() && 'attachment' == $previous->post_type) {
            return;
        }
        $prev_class = $next_class = '';
        if ($previous && has_post_thumbnail($previous->ID)) {
            $prev_class = " has-post-thumbnail";
        }
        if ($next && has_post_thumbnail($next->ID)) {
            $next_class = " has-post-thumbnail";
        }
        ?>
	<nav class="navigation post-navigation" role="navigation">
		<h1 class="screen-reader-text"><?php 
        esc_html_e('Post navigation', 'twentyfifteen');
        ?>
</h1>
		<div class="nav-links">
			<?php 
        if (is_attachment()) {
            previous_post_link('<div class="nav-previous' . $prev_class . '">%link</div>', _x('<span class="meta-nav">Published In</span><span class="post-title">%title</span>', 'Parent post link', 'twentyfifteen'));
        } else {
            previous_post_link('<div class="nav-previous' . $prev_class . '">%link</div>', _x('<span class="meta-nav">Previous</span><span class="post-title">%title</span>', 'Previous post link', 'twentyfifteen'));
            next_post_link('<div class="nav-next' . $next_class . '">%link</div>', _x('<span class="meta-nav">Next</span><span class="post-title">%title</span>', 'Next post link', 'twentyfifteen'));
        }
        ?>
		</div><!-- .nav-links -->
	</nav><!-- .post-navigation -->
	<?php 
    }
开发者ID:justatechnology,项目名称:Security,代码行数:39,代码来源:template-tags.php

示例12: blue_planet_post_nav

    /**
     * Display navigation to next/previous post when applicable.
     *
     * @deprecated 2.1 Use the_post_navigation()
     */
    function blue_planet_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 
        esc_html_e('Post navigation', 'blue-planet');
        ?>
</h1>
		<div class="nav-links">
			<?php 
        previous_post_link('%link', '<span class="meta-nav">&larr;</span> %title');
        ?>
			<?php 
        next_post_link('%link', '%title <span class="meta-nav">&rarr;</span>');
        ?>
		</div><!-- .nav-links -->
	</nav><!-- .navigation -->
	<?php 
    }
开发者ID:jbbythebch,项目名称:client1wp_test,代码行数:30,代码来源:template-tags.php

示例13: apostrophe_post_nav

    /**
     * Display navigation to next/previous post when applicable.
     *
     * @return void
     */
    function apostrophe_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 
        esc_html_e('Post navigation', 'apostrophe');
        ?>
</h1>
		<div class="nav-links">
			<div class="nav-previous">
			<?php 
        previous_post_link('%link', '<span class="meta-nav">' . _x('Previous', 'Previous post link', 'apostrophe') . '</span> <span class="apostrophe-post-title">%title</span>');
        ?>
			</div>
			<div class="nav-next">
				<?php 
        next_post_link('%link', '<span class="meta-nav">' . _x('Next', 'Next post link', 'apostrophe') . '</span> <span class="apostrophe-post-title">%title</span>');
        ?>
			</div>
		</div><!-- .nav-links -->
	</nav><!-- .navigation -->
	<?php 
    }
开发者ID:glugpace,项目名称:glugpace.org,代码行数:34,代码来源:template-tags.php

示例14: cover_post_nav

    /**
     * Display navigation to next/previous post when applicable.
     *
     * @return void
     */
    function cover_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', 'cover');
        ?>
</h1>
		<div class="nav-links cf">
			<?php 
        if ($previous) {
            previous_post_link('<div class="nav-previous">%link</div>', _x('<h2 class="subtitle">' . __('Previous post', 'cover') . '</h2><h1 class="title">%title</h1>', 'Previous post link', 'cover'));
        }
        if ($next) {
            $next_img_array = wp_get_attachment_image_src(get_post_thumbnail_id($next->ID), 'single-post-thumbnail');
            $next_img = $next_img_array[0];
            $class = '';
            $style = '';
            if ('' != $next_img) {
                $class = ' featured-image';
                $style = ' style="background-image: url(\'' . $next_img . '\')"';
            }
            next_post_link('<div class="nav-next">%link</div>', _x('<div class="cover' . $class . '"><div class="cover-background"' . $style . '></div><div class="cover-header"><h2 class="cover-subtitle">' . __('Next post', 'cover') . '</h2><h1 class="cover-title">%title</h1></div></div>', 'Next post link', 'cover'));
        }
        ?>
		</div><!-- .nav-links -->
	</nav><!-- .navigation -->
	<?php 
    }
开发者ID:9x,项目名称:cover,代码行数:40,代码来源:template-tags.php

示例15: sunspot_content_nav

/**
 * Display navigation to next/previous pages when applicable
 *
 * @since Sunspot 1.0
 */
function sunspot_content_nav( $nav_id ) {
	global $wp_query;

	$nav_class = 'site-navigation paging-navigation';
	if ( is_single() )
		$nav_class = 'site-navigation post-navigation';

	?>
	<nav role="navigation" id="<?php echo $nav_id; ?>" class="<?php echo $nav_class; ?>">
		<h1 class="assistive-text"><?php _e( 'Post navigation', 'sunspot' ); ?></h1>

	<?php if ( is_single() ) : // navigation links for single posts ?>

		<?php previous_post_link( '<div class="nav-previous">%link</div>', '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'sunspot' ) . '</span> %title' ); ?>
		<?php next_post_link( '<div class="nav-next">%link</div>', '%title <span class="meta-nav">' . _x( '&rarr;', 'Next post link', 'sunspot' ) . '</span>' ); ?>

	<?php elseif ( $wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() ) ) : // navigation links for home, archive, and search pages ?>

		<?php if ( get_next_posts_link() ) : ?>
		<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'sunspot' ) ); ?></div>
		<?php endif; ?>

		<?php if ( get_previous_posts_link() ) : ?>
		<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'sunspot' ) ); ?></div>
		<?php endif; ?>

	<?php endif; ?>

	</nav><!-- #<?php echo $nav_id; ?> -->
	<?php
}
开发者ID:kevinreilly,项目名称:mendelements.com,代码行数:36,代码来源:template-tags.php


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