Show posts of category in a page

The way i’d do it: First – create a page in the wp admin. Then create a file like mypage.php. Save it in your theme and a the top of it, add this to tell wordpress that this is a custom page template: <?php /* Template Name: Custompage */ get_header(); ?> Note: it’ll also already … Read more

How to hide certain categories in wordpress dashboard?

Got an answer in the first version of this answer: /* * Hide Specified Categories (by ID) from Editors */ add_action( ‘admin_init’, ‘wpse_55202_do_terms_exclusion’ ); function wpse_55202_do_terms_exclusion() { if( current_user_can(‘editor’) ) add_filter( ‘list_terms_exclusions’, ‘wpse_55202_list_terms_exclusions’, 10, 2 ); } function wpse_55202_list_terms_exclusions($exclusions,$args) { return $exclusions . ” AND ( t.term_id <> 1 ) AND ( t.term_id <> 17 … Read more

Search by word, category, tag, author

You’ll want to add some radio buttons inside your search form. Then add a filter to your search: function filter_search( $query ) { if( $query->is_search ) { if ( isset($_GET[‘tag’]) ) // alter your search query here. } return $query; } add_filter( ‘pre_get_posts’ , ‘filter_search’ ); Influenced by http://wordpress.org/support/topic/how-to-add-search-filter-by-custom-values#post-1463329

How to get category id in single.php wordpress?

Use wp_get_post_categories() Retrieve the list of categories for a post. <?php wp_get_post_categories( $post_id, $args ) ?> Be aware that the function returns an array (of category ids) even if you only have one category in your post. The example below shows how categories are retrieved, and then additional information is retrieved for each category. $post_categories … Read more

How to add categories to products in woocommerce programatically? [closed]

I think the function you are looking for is called wp_insert_term() in WordPress core. Woocommerce uses WordPress-taxonomy called product_cat So if you want to add some categories for example phones: function wpse_insert_term() { wp_insert_term( ‘phones’, ‘product_cat’, // the taxonomy array( ‘description’=> ‘A yummy phone.’, ‘slug’ => ‘phone’, ) ); } add_action(‘init’, ‘wpse_insert_term’);

How to insert category and subcategory using ‘wp_insert_post’ function?

The argument description in the Codex entry for wp_insert_post() has exactly what you need (reformatted). ‘post_category’ => [ array(<category id>, <…>) ] //post_category no longer exists, try wp_set_post_terms() for setting a post’s categories So, per the Codex. Use wp_set_post_terms(). wp_set_post_terms( $post_id, array( 1, 2, 3), ‘category’, true ); For custom taxonomies: ‘tax_input’ => array( ‘taxonomy_name’ … Read more

Remove word “Category” from WooCommerce product page [closed]

This will definitely remove the word “category”. Add this code in functions.php.As you already know woocommerce_template_single_meta is the hook responsible for meta information of the single-product. File is present in /woocommerce/templates/single-product/meta.php. Either you can use the following code to edit the HTML of meta.php or you can copy the file meta.php to themes/your-theme/woocommerce/single-product/meta.php. Then edit … Read more