How to Change the Categories Order in the Admin Dashboard?

Found an answer in this answer. add_filter( ‘get_terms_args’, ‘wpse_53094_sort_get_terms_args’, 10, 2 ); function wpse_53094_sort_get_terms_args( $args, $taxonomies ) { global $pagenow; if( !is_admin() || (‘post.php’ != $pagenow && ‘post-new.php’ != $pagenow) ) return $args; $args[‘orderby’] = ‘slug’; $args[‘order’] = ‘DESC’; return $args; } The order may be ASC or DESC, and the orderby can be: count … Read more

How do the ‘tag’ and ‘category’ (default) taxonomies do ‘save_post’ action?

It’s informative to check out the /wp-admin/post.php file, that contains the edit_post() function that calls wp_update_post(), which is a wp_insert_post() wrapper. Here’s a skeleton for saving the assigned category terms: /** * Saving assigned category terms (skeleton) */ add_action( ‘admin_action_editpost’, function() { add_filter( ‘wp_insert_post_data’, function( $data, $parr ) { add_action( ‘save_post_post’, function( $post_ID, $post ) … Read more

WordPress Multiple Category Search

The problem is that in a url the ‘+’ sign is equivalent to a space so that’s how PHP sees it. If you use an action on parse_request you can make this work like so: add_action( ‘parse_request’, ‘category_search_logic’, 11 ); function category_search_logic( $query ) { if ( ! isset( $query->query_vars[ ‘cat’ ] ) ) return … Read more

How can I hide a category from Contributors in the edit/add new post screen?

Working Example in Oct 2020, Working answer, I went to different answers none of them works now in new WordPress. function hide_categories_for_specific_user( $exclusions, $args ){ if ( ((defined( ‘REST_REQUEST’ ) && REST_REQUEST) or $GLOBALS[‘pagenow’] === ‘edit.php’ ) && !current_user_can( ‘manage_options’ ) ) { // IDs of terms to be excluded $exclude_array = array(“12″,”16″,”17”); // CHANGE … Read more

How To Modify The Loop in archives.php To Have 11 Posts Per Page and CSS Styling

First, for layout and CSS styling, I would recommend creating template files for the contexts you want to customize; i.e. create a category.php and a tag.php for the category and tag index archive pages, respectively. In either case, copy archive.php (or, if it doesn’t exist, copy index.php), and rename the copy as category.php. Then, modify … Read more

exclude category from get_posts?

as ‘get_posts()’ uses the ‘WP_Query()’ parameters, i would assume that this should work: $laargsM = array( ‘cat’ => 7, ‘posts_per_page’ => 300, ‘orderby’ => ‘title’, ‘order’ => ‘asc’, ‘category__not_in’ => array(10) );

Woocommerce get category image full size

Thanks to Mike Jolley (Woocommerce plugin author) for the solution using: wp_get_attachment_image_src $prod_categories = get_terms( ‘product_cat’, array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘hide_empty’ => true )); foreach( $prod_categories as $prod_cat ) : $cat_thumb_id = get_woocommerce_term_meta( $prod_cat->term_id, ‘thumbnail_id’, true ); $shop_catalog_img = wp_get_attachment_image_src( $cat_thumb_id, ‘shop_catalog’ ); $term_link = get_term_link( $prod_cat, ‘product_cat’ );?> <a href=”https://wordpress.stackexchange.com/questions/200170/<?php echo … Read more

Catch 404 after changing permalink structure from /%postname%/ to /%category%/%postname%/

That happens because WordPress reads your old post name as category name now – and it cannot find that category. Solution: filter 404_template and try to find the post and its permalink. Then redirect. <?php # -*- coding: utf-8 -*- /* Plugin Name: Redirect to category */ add_filter( ‘404_template’, ‘t5_redirect_to_category’ ); function t5_redirect_to_category( $template ) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)