Displaying Posts by tag dynamically in WordPress

The tag.php template shouldn’t use a custom query for its posts at all. When you visit the link to a tag the main query is automatically populated with posts that have that tag. In the template you output the main query with the standard loop. <?php if ( have_posts() ) : ?> <?php while ( … Read more

Sort list of WordPress Page under tag when is_tag() called

You could merge order parameters into the query when it’s a tag page.. Replace the following lines. <?php /* If this is a tag archive */ if( is_tag() ) { ?> <h2>Lawyers in <i><?php single_tag_title(); ?></i> Practice Area:</h2> <?php } ?> with.. <?php if( is_tag() ) { $args = array_merge( array( ‘order’ => ‘asc’, ‘orderby’ … Read more

Get the latest tags in a cloud? [closed]

The default WordPress tag cloud cannot order by latest, it only works by displaying the “most used”, it does not accept any parameters to alter the query, only the layout. Tags are usually used in conjunction with posts and are not really meant to be an archive or category, so in order to display the … Read more

Is is possible to rebuild wp_term_relationships table?

If your AUTO_INCREMENT value wasn’t reset and your new posts will still have unique IDs and you can do: SELECT tr.*, p.ID FROM wp_term_relationships AS tr LEFT JOIN wp_posts AS p ON tr.object_id = p.ID WHERE p.ID is NULL; to see which term relationships are orphans and use a DELETE FROM to fix it.

Display custom list of tags in post/page editor with hooks

We can override the Ajax call to wp_ajax_get_tagcloud() and do a clean hack. <?php /* Plugin Name: Custom Admin Tag Cloud */ add_action( ‘wp_ajax_get-tagcloud’, ‘ajax_tag_cloud_wpse_99497’, 1 ); function ajax_tag_cloud_wpse_99497() { // PASTE ALL THE MODIFIED FUNCTION HERE // http://core.trac.wordpress.org/browser/tags/3.5.1/wp-admin/includes/ajax-actions.php#L639 } Restore your core files to its original state, copy the modified function inside the above … Read more

Exclude specific tags (by id) from the_tags

Not sure that this is the best decision, but you can use the filter to cut your special tag without modifying templates. add_filter(‘the_tags’, ‘wpse_320497_the_tags’); function wpse_320497_the_tags($tags) { $exclude_tag = ‘word’; // You can add your own conditions here // For example, exclude specific tag only for posts or custom taxonomy if(!is_admin() && is_singular()) { $tags … Read more

Efficient Tag Management?

I manage a blog with 3 editors and 8-10 contributors. In my experience, the best way to manage tags is to simply instruct contributors not to add tags to their own articles, and instead have the editors be responsible for tagging articles. You can then work with editors to agree on what the purpose of … Read more

Limit tag cloud terms by date

Well it’s not that it’s not possible it just means it will take some effort. I am able to use an SQL query that combines the posts, term_relationships and terms tables. This allows a tag or name to be associated with a post which was published on a particular date. This was the sql statement … Read more

Display all posts of current viewing tag

Ok .. after searching for a while I figured out what I was doing wrong. I wasn’t including custom post types in the loop. I ended up constantly with ‘not found’. Whats the solution: query_posts( array( ‘post_type’ => ‘blog’, ‘showposts’ => 3, ‘orderby’ => ‘rand’) ); if ( have_posts() ) : while ( have_posts() ) … Read more