Remove / Rename Uncategorized Category In WordPress

To change the default “Uncategorized” using code you can do the following: // Uncategorized ID is always 1 wp_update_term(1, ‘category’, array( ‘name’ => ‘hello’, ‘slug’ => ‘hello’, ‘description’ => ‘hi’ )); Read this: http://codex.wordpress.org/Function_Reference/wp_update_term

Display Image for a category using get_categories, or show an image from any child post

This is possible with a filter on get_terms. function grab_child_image($terms,$taxonomies,$args) { // var_dump($terms,$taxonomies,$args); // debug foreach ($terms as &$term) { $cp = new WP_Query( array ( ‘cat’ => $term->term_id, ‘fields’ => ‘ids’, ‘ignore_sticky_posts’ => true ) ); // var_dump($cp->posts); // debug if ($cp->have_posts()) { $attach = new WP_Query( array ( ‘post_parent__in’ => $cp->posts, ‘post_type’ => … Read more

How do I get the category URL from get_the_category?

Use: get_category_link( $category_id ); See: https://codex.wordpress.org/Function_Reference/get_category_link In your specific case: <?php global $post; $categories = get_the_category(); foreach ($categories as $category) : $exclude = get_the_ID(); $posts = get_posts(‘posts_per_page=4&category=’. $category->term_id); foreach($posts as $post) : if( $exclude != get_the_ID() ) { ?> <a href=”https://wordpress.stackexchange.com/questions/219954/<?php the_permalink(); ?>” title=”<?php the_title(); ?>” class=”post c-1″> Link to actual post</a> <?php } endforeach; … Read more

Completely disable categories

With most credit due to this stackexchange answer: function wpse120418_unregister_categories() { register_taxonomy( ‘category’, array() ); } add_action( ‘init’, ‘wpse120418_unregister_categories’ ); This technically leaves everything in place (so you could bring it back at any time without a loss of data), but it “unhooks” it from everywhere in the admin by removing it from all $object_types. … Read more

How to make child categories recognize parent’s template displays

Thanks to @Rarst for guiding me to the right direction. Using his direction I googled again and again and found a blog article of WerdsWords with an excellent bit of code snippet filtered to category_template as Rarst suggested me, and the good news is: it worked for my cause: function new_subcategory_hierarchy() { $category = get_queried_object(); … Read more

get_categories hierarchical order like wp_list_categories – with name, slug & link to edit cat

output as unordered list: <?php hierarchical_category_tree( 0 ); // the function call; 0 for all categories; or cat ID function hierarchical_category_tree( $cat ) { // wpse-41548 // alchymyth // a hierarchical list of all categories // $next = get_categories(‘hide_empty=false&orderby=name&order=ASC&parent=” . $cat); if( $next ) : foreach( $next as $cat ) : echo “<ul><li><strong>’ . $cat->name … Read more

Exclude the category from the WordPress loop

you could use wp_parse_args() to merge your arguments into the default query // Define the default query args global $wp_query; $defaults = $wp_query->query_vars; // Your custom args $args = array(‘cat’=>-4); // merge the default with your custom args $args = wp_parse_args( $args, $defaults ); // query posts based on merged arguments query_posts($args); although, i think … Read more

How to show subcategories in categories else show posts

Your code checks for child categories and shows them if they exist, but you aren’t then going on to process the loop that would ordinarily display the posts in the current category. You want to extend your code to be of the form: if ( is_category() ) { $this_category = get_category($cat); if ( get_category_children( $this_category->cat_ID … Read more

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