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

Use tag->slug instead of tag->name. Spaces and special characters will be replaced by dashes but altering that is easy: echo str_replace('-','_',$tag->slug); Reference http://codex.wordpress.org/Function_Reference/get_the_tags http://php.net/manual/en/function.str-replace.php


2

I can see that you are constructing an array with only one element, something like this: array( 'green, yellow, red' ) instead of an array with multiple elements: array( 'green', 'yellow', 'red' ) Try to replace these lines: $out .= $tag->name .','; $csv_tags .= '"<a href="/' . $tag->slug . '">' . $tag->name . '</a>"'; with ...


2

Here you go: function get_author_post_tags_wpa78489($author_id,$taxonomy = 'post_tag'){ //get author's posts $posts = get_posts(array( 'author' => $author_id, 'posts_per_page' => -1, 'fields' => 'ids' ) ); $ts = array(); //loop over the post and count the tags foreach ((array)$posts as ...


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 ...


1

If you read the Codex entry, you must pass an array as tag_slug__in. In this case though, I would use tag__in with IDs rather than slugs: $tag_ids = array(); foreach( get_the_tags($post->ID) as $tag ) { $tag_ids[] = $tag->term_id; } $recent_posts = new WP_Query( array( 'tag__in' => $tag_ids, 'posts_per_page' => 2, ...


1

When you do the following in your code $posttags = get_the_tags($item->term_id);, $item is referring to a post object, not a term object. Therefore, term_id is an invalid property. This should be throwing a PHP notice. While not certain, I think what you are intending to do is: $posttags = get_the_tags($item->ID); since get_the_tags takes a post ...


1

Double check that you don't have a check for has_excerpt() that's hiding the "auto-generated" excerpt. Even if get_the_excerpt() returns something made from post_content, has_excerpt() still returns false if the excerpt is empty. If that's not the case, see if there's a function that filters on get_the_excerpt that could be effecting this. To answer your ...



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