Get posts of a custom post type from category from taxonomy?

Since you’re using a custom taxonomy, you can’t use the category argument. You can find some information about custom taxonomy retrieval in this comment in the developer documentation. According to that, I think your $categoryArgs should be: $categoryArgs = array( ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘post_type’ => $type, ‘tax_query’ => array( array( ‘taxonomy’ => … Read more

How to choose the content from a post which is in the right category?

You can use the function in_category to test if a post is in a certain category. It takes one or more categories and the post as input. So you may differentiate your function like this: function title_content($atts, $content = null ) { global $wpdb; $post_id = $wpdb->get_var($wpdb->prepare(“SELECT ID FROM {$wpdb->posts} WHERE post_title = %s”,$content)); $getpost … Read more

How can I add a class to displays a category?

Instead of using the_category, I would just build the category links manually and add the category slug as the class name. Something like this: <span class=”post_into”> <?php $thelist=””; $i = 0; foreach( get_the_category() as $category ) { if ( 0 < $i ) $thelist .= ‘, ‘; $thelist .= ‘<a href=”‘ . esc_url( get_category_link( $category->term_id … Read more

Woocommerce search form with category select

You can try below code. Below code shows search box and woocommerce product categories . It will also show selected category. <form name=”myform” method=”GET” action=”<?php echo esc_url(home_url(“https://wordpress.stackexchange.com/”)); ?>”> <?php if (class_exists(‘WooCommerce’)) : ?> <?php if(isset($_REQUEST[‘product_cat’]) && !empty($_REQUEST[‘product_cat’])) { $optsetlect=$_REQUEST[‘product_cat’]; } else{ $optsetlect=0; } $args = array( ‘show_option_all’ => esc_html__( ‘All Categories’, ‘woocommerce’ ), ‘hierarchical’ => … Read more

How to hide some categories in dashboard

You could hook to the get_terms_args filter conditionally depending on your user/role Something along those lines add_filter( ‘get_terms_args’, ‘restrict_cat’, 10, 2 ); function restrict_cat( $args, $taxonomies ){ // Don’t run if we are not dealing with categories if( ‘category’ != $taxonomies[0] ) return $args; // The check for the user we want to restrict // … Read more