php 按ID将相邻的帖子导航添加到特定类别的帖子。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 按ID将相邻的帖子导航添加到特定类别的帖子。相关的知识,希望对你有一定的参考价值。

<?php

// Remove adjacent post nav.
add_action( 'after_setup_theme', function(){
	remove_post_type_support( 'post', 'genesis-adjacent-entry-nav' );
});

/**
 * Add adjacent post navigation to posts
 * in a specific category, by ID.
 */
add_action( 'wp_head', function() {
	// Bail if not a single post.
	if ( ! is_singular( 'post' ) ) {
		return;
	}
	// Bail if not in category with ID of 123
	if ( ! has_term( 123, 'category' ) ) {
		return;
	}
	// Add adjacent post nav.
	add_post_type_support( 'post', 'genesis-adjacent-entry-nav' );
});

以上是关于php 按ID将相邻的帖子导航添加到特定类别的帖子。的主要内容,如果未能解决你的问题,请参考以下文章