Tag Info

Hot answers tagged

6

I addressed a similar problem not long ago - it's all in the memory: $post_ids = get_posts( array( 'posts_per_page' => -1, 'post_status' => 'publish', 'fields' => 'ids', // Just grab IDs instead of pulling 1000's of objects into memory ) ); update_object_term_cache( $post_ids, 'post' ); // Cache all the post terms ...


5

You are hiting the db with a 500 mile per hour hurricane, no wonder your query times out. Here is an idea or two to speed things up Add 'fields' => 'ids', to your WP_Query arguments. This will speed up your query dramatically. This will only return the post id's, and this is the only thing that you actually need Use wp_get_post_terms() to get the post ...


3

Take a look at custom variables for Google Analytics. In that case you would need to parse all used tags as one string (maybe separated by | for example), because it's better to use one variable name and each variable can take one value per pageview. Another option would be using events, using a category (named tags for example), which you could repeat for ...


2

This same exact question was asked earlier this week or over the weekend, and it had me thinking. Here is the idea that I came up with. If you look at the source code of the WP_Query class, you will see that sticky posts is only added to the first page of the home page. There is also no filter supplied to change this behavior in order to set the required ...


2

By get_the_tags() you receive an array of tags attached to the current post. So you could do the following: $tags = get_the_tags(); $tag_ids_to_print = array( 1, 2, 3 ); //List of Tag IDs which you want to be printed $print_tags = array(); if( is_array( $tags ) ){ foreach( $tags as $tag ){ if( in_array( $tag->term_id, $tag_ids_to_print ) ) ...


2

Frequency table - custom SQL query: You can try the following custom query for your posts/terms statistics for a given taxonomy, post status and type: /** * Frequency data: Count how many posts have a given number of terms, * for a given post type, post status and taxonomy. * * @param string $taxonomy Taxonomy slug * @param string $post_status ...


2

You can build a stack of unique tags, then loop over them again to output. Couple of extra things though - never use query_posts. Secondly, you can be way more efficient in your querying and save a lot of memory in the process: $post_ids = get_posts( array( 'posts_per_page' => -1, 'category_name' => 'testing', 'fields' ...


2

WordPres has a function that extract IPTC info from images, that function is wp_read_image_metadata. That function is only available on admin side and, according with the codex, it doesn't extract IPTC keywords. But you can use iptcparse from PHP at your own to extract IPTC keywords and set them as post tags. In your question, you said that you have already ...


1

I think this is more a general question than a specific one and I'll be treating it as such. Taxonomies in general are used to group posts together that shares the same characteristic. The post_tag and category taxonomies are the most widely and commonly used of the four build in taxonomies to achieve this. Also very popular are custom taxonomies which ...


1

Custom Field Tag filter: You can try the following code snippet to filter tags from a custom field: /** * Support the 'include_tags' custom field (comma seperated tag slugs) * to filter out those tags to display. * * @see http://wordpress.stackexchange.com/a/183929/26350 */ ! is_admin() && add_filter( 'get_the_terms', function( $terms, ...


1

As you have already pointed out in your question, custom taxonomies are the way to go here. For this taxonomy to behave like the build in taxonomy post_tag, you need to set the hierarchical parameter to false. To make these taxonomy available to only your two specific post types, you need to specifiy this when registering your taxonomy. Example ...



Only top voted, non community-wiki answers of a minimum length are eligible