Set homepage to only display posts from one tag

You should use pre_get_posts to alter the main query on the home page. With the proper conditional tags and parameters (check WP_Query for available parameters) you can achieve what you need You can do the following to just display posts from a given tag on your homepage add_action( ‘pre_get_posts’, function ( $query ) { if … Read more

Link directly to the first post in an archive

try this ( untested and assuming of course that $tag is the right object tag and $tag[‘count’] is the number of post with that tag ): if ( $tag[‘count’] > 1 ) { //first part of your code } else if($tag[‘count’] == 1){ $the_query = new WP_Query( ‘tag=’.$tag[‘name’] ); if ( $the_query->have_posts() ) { while … Read more

How to add class on term link?

I think you should use a custom loop: <?php $terms = get_the_terms( $post->ID, ‘product_tag’ ); if ($terms && ! is_wp_error($terms)): ?> <?php foreach($terms as $term): ?> <a href=”https://wordpress.stackexchange.com/questions/130622/<?php echo get_term_link( $term->slug,”product_tag’); ?>” rel=”tag” class=”<?php echo $term->slug; ?>”><?php echo $term->name; ?></a> <?php endforeach; ?> <?php endif; ?>

WP API Get post with tag names instead of tag ID’s

I figured something out based on what I found at this post. Basically I need a plugin that listens for when the REST response is about to go out. The plugin code would be similar to the following: function ag_filter_post_json($response, $post, $context) { $tags = wp_get_post_tags($post->ID); $response->data[‘tag_names’] = []; foreach ($tags as $tag) { $response->data[‘tag_names’][] … Read more

How can I remove certain HTML tags from the RSS feed?

You haven’t specified how it doesn’t work 🙂 Does it remove some links or doesn’t do anything at all. Anyway, to alter the content of every RSS item you can use rss_item() hook, or rss2_item() depending which stream is your target. add_filter(‘rss_item’, ‘custom_item_content’); function custom_item_content($content) { // alter your $content here return $content; }

require one tag for each post

Have fun. This works for any post type (including customs) that supports the ‘post_tag’ taxonomy. 99.9% of the time, it will apply only to ‘post’ post type. But we make compatible stuff 😉 /* Plugin Name: Single Postag Description: Enforces use of single ‘post_tag’ taxonomy on select posts. Author: EarnestoDev Version: 1.0.0 Author URI: http://www.earnestodev.com/ … Read more

how to change # of tag posts on /tag page?

I would put this in functions.php: function main_query_mods( $query ) { // check http://codex.wordpress.org/Conditional_Tags to play with other queries if(!$query->is_main_query()) { return; } if(is_tag()) { $query->set(‘posts_per_page’,15); } } add_action( ‘pre_get_posts’, ‘main_query_mods’ );

display tag slug as class per link in tag cloud

one possible way: add a filter in functions.php of your theme: add_filter ( ‘wp_tag_cloud’, ‘tag_cloud_slug_class’ ); function tag_cloud_slug_class( $taglinks ) { $tags = explode(‘</a>’, $taglinks); $regex = “#(.*tag-link[-])(.*)(‘ title.*)#e”; foreach( $tags as $tag ) { $tagn[] = preg_replace($regex, “(‘$1$2 tag-‘.get_tag($2)->slug.’$3’)”, $tag ); } $taglinks = implode(‘</a>’, $tagn); return $taglinks; }