New answers tagged

1

I needed some modifications(original see Pieters answer) to get it to work just on category pages. This solution will display all sticky posts of the current category (and child categories), but not on search, tag and single pages: add_action( 'pre_get_posts', function ( $q ) { if ( !is_admin() && $q->is_main_query() &&...


1

has_tag() is a function that will check if a post has a certain tag You could integrate it into your code like so: function my_category_templates($single_template) { global $post; if ( in_category( 'raspee' )) { $single_template = dirname( __FILE__ ) . '/single-raspee.php'; } if ( has_tag( 'everyone' )) { $single_template = dirname( __FILE__ )...


1

To expand your conditional to check for display of one of your terms, you can do this: if ( is_page() ) { the_title(); } elseif ( is_tag() ) { single_tag_title(); } elseif ( is_tax( 'mtags' ); ) { single_term_title('More Tags: '); } However, if you use your theme's custom taxonomy template for this taxonomy, taxonomy-mtags.php, then you can ...


1

At first glance, that should just work, as long as you've flushed your rewrite rules. You can do that by going into the settings and saving permalinks again.


0

This seems to be a core bug, spotted at 4.5 as well. Although documentation implies otherwise, you can not select in practice terms of non hierarchical taxonomies with the "checkoxed" metabox, the only working option is the "tag" style metabox.


0

The existing answer here is excellent, but unfortunately due to the answer's age it does not work for newer versions of WordPress. The code below improves in two ways: 1 - It's the recommended / best practice method for newer versions of WordPress, as of version 2.8 2 - It allows you to select the taxonomy through the dashboard widget interface, rather ...


0

Correct code: function tags_after_single_post_content($content) { $posttags = get_the_tags(); if ($posttags) { $array = []; foreach($posttags as $tag) { $array[] = '<a href="/tag/' . $tag->slug . '/">' . $tag->name . '</a>'; } $content .= 'Tags: ' . implode(', ', $array) . '<br>'; } return $content; } ...


0

Create Custom Post Type function create_product() { $labels = array( 'name' => _x( 'Product', 'post type general name', 'stacy' ), 'singular_name' => _x( 'product', 'post type singular name', 'stacy' ), 'menu_name' => _x( 'Products', 'admin menu', 'stacy' ), 'name_admin_bar' => _x( 'Product', '...


0

Talk about resurrecting an old question.... I had to do this recently with WordPress 4.5.3 and it didn't work at all. To make it work, I needed to wrap up the if statement in a function called by wp_head - like so: function remove_shortlink() { if( is_page(2) ) { remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); } } add_action( '...


0

There's probably a few ways to do this. The key will be cutting down on the number of loops you need to make it more efficient. I think this will work: $query = new WP_Query( array( 'post_type' => 'product', 'posts_per_page' => '-1', // unlimited posts 'tax_query' => array( array( 'taxonomy' => 'product_tag', ...


0

From the WP-Admin. Click on Appearance > Menus In the top right, click "Screen Options" Select (check) "CSS Classes" Then you will have added the optional "CSS CLASSES" to each menu item.



Top 50 recent answers are included