Remove a category ID from related post.
-
Hi,
I have 3 categories (music , song, jpop) now and wanna remove song and jpop categories from related post.
How can I do it ?
———————————————————————————————————-
if ( get_theme_mod(‘related-posts-on’, true) ) :
// Get the taxonomy terms of the current page for the specified taxonomy.
$terms = wp_get_post_terms( get_the_ID(), ‘category’, array( ‘fields’ => ‘ids’ ) );// Bail if the term empty.
if ( empty( $terms ) ) {
return;
}// Posts query arguments.
$query = array(
‘post__not_in’ => array( get_the_ID() ),
‘tax_query’ => array(
array(
‘taxonomy’ => ‘category’,
‘field’ => ‘id’,
‘terms’ => $terms,
‘operator’ => ‘IN’
)
),
‘posts_per_page’ => 6,
‘post_type’ => ‘post’,
); -
Hi there,
On what site is this, please? It looks like you’re trying to modify your theme’s files directly, which is not possible on WordPress.com sites, and we do not provide support for that type of customization, even for self-hosted WordPress themes developed by Automattic.
If you’re using the open source WordPress software, please post in the self-hosted WordPress forums instead for help with this:
- The topic ‘Remove a category ID from related post.’ is closed to new replies.