show category in woocommerce

within a category you can use get_queried_object() to get data on the current category. $current_category = get_queried_object(); $args = array( ‘categories’ => $current_category->term_id ); $tags = get_category_tags( $args );

Change Default Content when Creating a Post based on Previous Category Choice

You should have linked to the original Q&A since the beginning… Another great code from @JanFabry, btw 🙂 Force category choice before creating new post? Using exactly the code provided in his answer, this is how to make the filter default_content work: add_filter( ‘default_content’, ‘wpse_71772_default_content’, 10, 2 ); function wpse_71772_default_content( $content, $post ) { if( … Read more

Editing Loop So It Targets Specific Tags?

Use the pre_get_posts action to modify the main query. Place this in your functions.php file: function wpa71787_home_tag_query( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘tag’, ‘reviews’ ); } } add_action( ‘pre_get_posts’, ‘wpa71787_home_tag_query’ ); You can set any valid parameters of WP_Query with this method. Edit, secondary query excluding tagged posts, use … Read more

Make wp_dropdown_categories into a variable that persists until changed?

Just use the selected argument: wp_dropdown_categories( array( ‘show_option_all’ => ‘All Deployments’, ‘hierarchical’ => true, ‘show_count’ => true, ‘selected’ => get_query_var( ‘cat’ ), )); Update: Hook onto the tag_link filter & add the current category (if applicable): add_filter( ‘tag_link’, ‘wpse_71874_tag_link_category_context’ ); function wpse_71874_tag_link_category_context( $link ) { if ( is_category() && $cat_id = get_queried_object_id() ) $link = … Read more

Custom url structure – pages under a custom post type

example.com/event/london-2012/speakers/john-doe You need an “event” post type and a “speaker post type. The event post type should be hierarchical and should have a sub-page called “speakers” which should use a custom template that displays all the “speaker” post types assigned to that event (see the Posts 2 Posts plugin). Then you can create other sub-pages … Read more

Natural sort / ordering wp_dropdown_categories

not the best way (at least if you have a lot of tags) add_filter(‘get_terms_orderby’, ‘get_terms_orderby_natural_slug’,10,2); wp_dropdown_categories( ‘taxonomy=week&hierarchical=1&orderby=slug’ ); remove_filter(‘get_terms_orderby’, ‘get_terms_orderby_natural_slug’); function get_terms_orderby_natural_slug($orderby, $args){ $orderby = “SUBSTR({$orderby} FROM 1 FOR 5), CAST(SUBSTR({$orderby} FROM 6) AS UNSIGNED), SUBSTR({$orderby} FROM 6)”; return $orderby; } but still this is a way to do that…

Related posts widget – category

Change function widget() as below global $post; // Get array of category ID’s from current Post $post_categories = wp_get_post_categories( $post->ID ); // Get array of post info. if(isset($post_categories) && is_array($post_categories) && count($post_categories) > 0){ $cat_posts = new WP_Query(“showposts=” . $instance[“num”] . “&cat=” . $post_categories); } else { $cat_posts = new WP_Query(“showposts=” . $instance[“num”] . “&cat=” … Read more

How can I use AJAX with check-box categories?

You’ll need to hook into the “onchange” event of javascript. When using jquery, it’s as simple as $(‘<the selector string>’).change(function(){}); When ever the values are changed, you’ll do an AJAX request to the server with the new parameters & populate the output screen with the new result. For the server-side, you’ll check the parameters, do … Read more

Pagination for a category

The problem exists because you are using query_posts(), instead of properly filtering the main query via pre_get_posts. Remove your query_posts() call from the template file, then add the following to functions.php: function wpse74325_pre_get_posts( $query ) { if ( $query->is_main_query() && is_category( 5 ) ) { $query->set( ‘posts_per_page’, ’20’ ); } } add_action( ‘pre_get_posts’, ‘wpse74325_pre_get_posts’ ); … Read more