Conditional tags don’t work

is_singular will return false on an archive page. If you wanted to check if you are on an archive for a post type, you would use is_post_type_archive( ‘libri’ ) , or you can create an archive-{post_type}.php file, which on this case would be archive-libri.php References: https://codex.wordpress.org/Post_Type_Templates https://codex.wordpress.org/Conditional_Tags#A_Single_Post_Page

How to Get Current Custom Post Type Selected Taxonomy Term (Not All Terms)

There are several ways to achieve this. Using get_the_terms: $args = array( ‘post_type’ => ‘movies’, ‘posts_per_page’ => 10 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php the_title(); $terms = get_the_terms( get_the_ID(), ‘genre’ ); if ( is_array( $terms ) ) { //Manipulate array of WP_Term objects } ?> <div … Read more

Display Posts in Custom Post Types Timber

It’s a late reply and I suspect you might have it figured out already, but if someone is looking for the same info, here’s an example. {% for post in posts %} {% set post_terms = post.terms(‘tour_category’) %} {% if function( ‘has_term’, ‘Sightseeing Tours’, ‘tour_category’ ) %} {% set teaser=”sightseeing” %} {% elseif function( ‘has_term’, … Read more

Pagination is not working on single-{slug}.php but works fine on page-{slug}.php

You forgot to start a new query. And if you dont use have post on your custom query, you will get the main current query, in your case is your single. $args = array( ‘post_type’ => ‘crew’, ‘posts_per_page’ => 10 ); $your_custom_query = new WP_Query( $args ); // is that you forgot // The Loop … Read more

How can I display an archive of only one category of my custom post type?

Try this and let us know if it works: function custom_category_rewrite() { /** * Here you build an array containing the post type keys that you want * the rule to work for. */ $custom_post_types = array(‘podcast’); foreach ( $custom_post_types as $post_type ) { /** * Adds rewrite rule which will rewrite sth like http://yoursite.com/podcast/category/category-name/ … Read more

Custom page template for category taxonomy

The hierarchy for custom taxonomies is: taxonomy-$taxonomy-$term.php taxonomy-$taxonomy.php taxonomy.php archive.php index.php So, if your taxonomy was called cats, you could target that specific taxonomy with a template file taxonomy-cats.php. If you wanted to style your tabby cats differently than the rest (because of course you would), then you could use taxonomy-cats-tabby.php. See wphierarchy.com