Include category name in page template
You can use get_queried_object to return the name of the current category page you are on $cc = get_queried_object(); echo $cc->cat_name; //display the name of current category page
You can use get_queried_object to return the name of the current category page you are on $cc = get_queried_object(); echo $cc->cat_name; //display the name of current category page
You’ll want to have a look at get_the_terms(). <?php // You need to define the post id from the post you are outputting in the right bar so that the left bar knows how to match up the terms $country = get_the_terms( $post->id, ‘countries’ ) $args = array( ‘post_type’ => ‘side_menu’, ‘posts_per_page’=> 1, ‘tax_query’ => … Read more
I figured it out! After a lot of research and trial and error, I managed to figure out how to get the paging to work for both versions…my original code and the simplified code update. Original Code Solution: <?php $cat = get_cat_ID(“Photos”); $categories = get_categories(“child_of=$cat”); $limit = 9; $total = count($categories); $pages = ceil($total / … Read more
Most efficient way to have 1 template for parent, 1 template for child categories?
This question has the same solution as that one. The answer is short, so I post it here as well: In WordPress 3.9 (and still in 3.9.1) there’s a bug concerning the excluded terms in get_adjacent_post(). There’s a plugin to fix that bug.
Depending on whether you intend to use this template to display other categories elsewhere, you may need a copy of the Portfolio Template file, named for this category. To select a single category for display, from post type ‘portfolioitems’, modify the following line: $wp_query = new WP_Query(array(‘post_type’ => ‘portfolioitems’,’posts_per_page’ => 50,’paged’=> $paged)); To: $wp_query = … Read more
just an update: I used the plugin WP Permastructure to solve the issue by adding /%category%/%postname%/ in the “category” section on the bottom of the permalinks settings page (the permalink adds new fields). Not really sure why this works but changing the permalink structure normally does not.
You could use the get_terms_orderby filter: add_filter( ‘get_terms_orderby’, ‘wpse156153_get_terms_orderby’, 10, 3 ); $categories=get_categories($cat_args); remove_filter( ‘get_terms_orderby’, ‘wpse156153_get_terms_orderby’, 10, 3 ); with function wpse156153_get_terms_orderby($orderby, $args, $taxonomies ) { return ‘FIELD(t.term_id, ‘ . $args[‘include’] . ‘)’; }
Display posts that have this category (not children of that category), using category id: $cat_post = new WP_Query( ‘category__in=4’ ); // you will replace the 4 with your category ID if( $cat_post->have_posts()){ while( $cat_post->have_posts()): $cat_post->the_post(); // NOW RIGHT THE CODE AS PER YOUR DESIGN endwhile; }
There are probably several approaches to doing this. One approach would be to select the categories and comments divs in your theme and use css to remove them. Example: In your style.css .entry-utility-prep-cat-links { display:none; }