jasongeiger
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Get Tags specific to CategorySaku4388
The best way to go about it is to run custom sql queries for what you want to retrieve.
I would recommend looking through some of the custom queries that have been given above to get familiar with custom sql queries.
The thing is: grabbing tags and categories is already pretty intense to follow, adding post meta is only going to make it more difficult because you are adding another table to the mix.
Good Luck!
Forum: Developing with WordPress
In reply to: Get Tags specific to CategoryThe goal of this was to be able to batch tags based on the category to develop a category specific list of tags, which in turn linked to that tags filtered archive.
Forum: Developing with WordPress
In reply to: Get Tags specific to CategoryThis what I’ve come up with. I think apljdi, is right about custom query. This still seems a bit excessive.
<?php $project_query = query_posts('category_name=projects'); while (have_posts()) : the_post(); $posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { $all_tags_arr[] = $tag -> name; //USING JUST $tag MAKING $all_tags_arr A MULTI-DIMENSIONAL ARRAY, WHICH DOES WORK WITH array_unique } } endwhile; ?> <?php if ( is_array($all_tags_arr) && count($all_tags_arr) > 0 ): ?> <?php $tags_arr = array_unique($all_tags_arr); //REMOVES DUPLICATES foreach( $tags_arr as $tag ): $el = get_term_by('name', $tag, 'post_tag'); $arr[] = '"tag-'.$el->slug.'"'; ?> <span><a href="#<?php echo $el->slug; ?>" id="taglink-tag-<?php echo $el->slug; ?>" rel="tag-<?php echo $el->slug; ?>"><?php echo $el->name; ?></a> <span class="slash">//</span></span> <?php endforeach; ?>
Forum: Themes and Templates
In reply to: get name of page template on a pagegreenshady, that works great.
I’m wonder how to extend it to include the default templates like: archive, single, search, etc.
Forum: Developing with WordPress
In reply to: Get Tags specific to CategoryElectric Studio, that’s not exactly what I was looking for but it was good stepping stone.
<?php query_posts('category_name=work'); if (have_posts()) : while (have_posts()) : the_post(); $posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { $all_tags_arr[] = $tag -> name; //USING JUST $tag MAKING $all_tags_arr A MULTI-DIMENSIONAL ARRAY, WHICH DOES WORK WITH array_unique } } endwhile; endif; $tags_arr = array_unique($all_tags_arr); //REMOVES DUPLICATES echo '<pre>'.print_r($tags_arr, true).'</pre>'; //OUTPUT FINAL TAGS FROM CATEGORY ?>
This does the job, except it would be nice to have $tags_arr as a multi-dimensional array but that does work with array_unique.
Still my question is, if you have say 100 posts in a category, is doing query like this the most efficient way of getting these results.