When ‘is_post_type_archive()’ return true?
When ‘is_post_type_archive()’ return true? is_post_type_archive() returns true for custom post type archives and false for default posts. Use is_archive() to check for default posts.
When ‘is_post_type_archive()’ return true? is_post_type_archive() returns true for custom post type archives and false for default posts. Use is_archive() to check for default posts.
The register_post_type has_archive option also accepts a string. That string will be used for the archives. See the changes in the code below: function create_reviews_post_type() { register_post_type(‘acme_reviews’, array( ‘labels’ => array( ‘name’ => __(‘Reviews’), ‘singular_name’ => __(‘Review’) ), ‘menu_position’ => 5, ‘public’ => true, ‘has_archive’ => ‘reviews’, ); } add_action(‘init’, ‘create_reviews_post_type’);
You’ve added the filter lm_exclude_bio to pre_get_posts. So when you need to run another query you can remove the filter to get normal query. You can remove the filter like below- // Here we’re removing the filter first. Then we are running the query. remove_filter( ‘pre_get_posts’, ‘lm_exclude_bio’ ); $args = array( ‘post_type’ => ‘bio’, ‘posts_per_page’ … Read more
Since 4.9. if ( get_the_post_type_description()) { echo get_the_post_type_description(); } redeclaring the function will crash WordPress.
is_archive() doesn’t accept any parameter and return true for every archive page: Categories, tag, date, author, …. I think what you need is to check if you are in a category page (in a archive of the category taxonomy) or in the blog home: if ( is_category() || is_home() ) { wp_register_script(‘isotope’, get_template_directory_uri() . ‘/js/jquery.isotope.min.js’, … Read more
Your desired URLs: www.example.com/results/post-name/ www.example.com/results/categories/category-name/ Two changes from your original code: Priority was added to both add_action hooks to reverse the order they execute. Order matters in this case, because the post type’s attachment rewrite rules override the taxonomy rewrites. Side-effect: attachment URLs don’t work for this post type! Rewrite for the taxonomy was changed … Read more
There doesn’t appear to be one, but the following should work: //Get post type $post_type_obj = get_post_type_object( get_post_type() ); //Get post type’s label $title = apply_filters(‘post_type_archive_title’, $post_type_obj->labels->name ); $archive_title = apply_filters(‘post_type_archive_title’, $post_type_obj->labels->all_items); This can, for instance, be put in one generic header template that is applied to all single-cpt files. With is_single() it can be … Read more
is_product_category() is to be used on woocommerce category archive pages only so first make sure that you are on category archive. instead of category number use category slug name is_product_category(‘category-slug’) no need to run OR(||) condition just use is_product_category(‘category-slug1′,’category-slug2’) to get same output
Run a conditional check in the foreach loop using is_category($term-name) Assign a class variable to active if it’s the same as $term->name $terms = get_terms( ‘category’ ); echo ‘<ul>’; foreach ( $terms as $term ) { $class = ( is_category( $term->name ) ) ? ‘active’ : ”; // assign this class if we’re on the … Read more
You can use the WooCommerce hook woocommerce_after_add_to_cart_button. This hook will add content after the “Add To Cart” button. If the customer clicks on this button, the product should get added to the cart, and the customer should be send to the checkout page. Add the below code in your child theme functions.php /* Create Buy … Read more