xmlsf_news_keywords

Filters the news keywords array. Passes the post exclusion flag and $post_id; must return an array.

apply_filters( 'xmlsf_news_keywords', array[] $keywords, int[] $post_id )

Used in xml-sitemap-feed/views/feed-sitemap-news.php

Parameters (2)

  • $keywords
    (array) The news keywords array.
  • $post_id
    (int) The current post ID.

Return

  • (array) The news keywords array.

The filter should return an array with keywords for the current post.

Usage example

function my_custom_keywords( $keywords ) {
	global $post;

	$terms = get_the_terms( $post->ID, 'post_tag' );
	$names = array();

	if ( $terms && ! is_wp_error( $terms ) ) {
		foreach ( $terms as $term ) {
			if ( is_object($term) && !empty($term->name) )
				$names[] = $term->name;
		}
	}
	$keywords = array_merge( (array) $keywords, $names );

	return $keywords;
}
add_filter( 'xmlsf_news_keywords', 'my_custom_keywords' );

Related

Used byDescription
none