Return selected categories only in custom page meta box?
Figured it out, I was using the wrong function. Correct function was get_the_category_by_ID($cat);
Figured it out, I was using the wrong function. Correct function was get_the_category_by_ID($cat);
Aren’t you supposed to have single quotes around paged in $args = array( ‘post_type’ => ‘resources’, ‘posts_per_page’ => 10, ‘cat’ => $cat_id, paged => $paged ); like so: $args = array( ‘post_type’ => ‘resources’, ‘posts_per_page’ => 10, ‘cat’ => $cat_id, ‘paged’ => $paged );
This is no solution, just an explanation: WordPress currently doesn’t have taxonomy meta data. You could add a stand alone table to add meta data there. Anyway, it’s not recommended to add your taxonomy/category/tag meta data to the options table as this one wasn’t made to get JOINed to do meta queries by it. My … Read more
Did you create taxonomy-{your-slug}.php template ? let’s say the slug is ‘locations‘ so, it will be something like this taxonomy-locations.php if you haven’t created yet, create one and the template codes will look like this , <?php /** * Locations taxonomy archive */ get_header(); $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); … Read more
Take a look at multiple loops for examples And also look at the content.php file in the Twenty Fourteen theme <?php // The Query $category_query = new WP_Query( ‘category__in=11’ ); // The Loop if ( $category_query->have_posts() ) { echo ‘<ul>’; while ( $category_query->have_posts() ) { $category_query->the_post(); echo ‘<li>’ . get_the_title() . ‘</li>’; } echo ‘</ul>’; … Read more
If the only issue you want to correct is the output of single_tag_title, you can correct the value via a filter by grabbing the tag query var directly: function wpa90852_fix_tag_title(){ $tag = get_term_by( ‘slug’, get_query_var(‘tag’), ‘post_tag’ ); return $tag->name; } add_filter( ‘single_tag_title’, ‘wpa90852_fix_tag_title’ );
I managed to solve this in a procedural way: 1 added in theme function this snippet: add_action(‘template_redirect’, ‘load_category_tree_template’); function load_category_tree_template() { if (is_category() && !is_feed()) { // replace ‘your-base-category-slug’ with the slug of root category $base_tree_cat_id = get_cat_id(‘your-base-category-slug’); // get current category id $catid = get_query_var(‘cat’); if (is_category($base_tree_cat_id) || cat_is_ancestor_of($base_tree_cat_id, $catid)) { load_template(STYLESHEETPATH . ‘/category-your-base-category-slug.php’); … Read more
Are you looking for a list of the current post’s categories and parents, or just a general list of categories? If the former, you can use get_category_parents(). If you’re in The Loop, for example: <?php if( have_posts() ) : while( have_posts() ) : the_post(); // Post stuff // … $cats = wp_get_post_categories( $post->ID ); foreach( … Read more
Could try a plugin called Geo mash up which turns WordPress into a GeoCMS, has nearby functionality built into it and can take long and lang values or addresses from custom fields. http://wordpress.org/extend/plugins/geo-mashup/ and try https://code.google.com/p/wordpress-geo-mashup/wiki/TagReference for the references.
Well first of all, we can get rid of all the query_posts business in the template. There’s always a better method than using query_posts. If the primary goal is to have 5 posts on the first page and 4 on all subsequent pages, we can do that very easily before the query happens via a … Read more