How to get category id of current post?

function catName($cat_id) { $cat_id = (int) $cat_id; $category = &get_category($cat_id); return $category->name; } function catLink($cat_id) { $category = get_the_category(); $category_link = get_category_link($cat_id); echo $category_link; } function catCustom() { $cats = get_the_category($post->ID); $parent = get_category($cats[1]->category_parent); if (is_wp_error($parent)){ $cat = get_category($cats[0]); } else{ $cat = $parent; } echo ‘<a href=”‘.get_category_link($cat).'”>’.$cat->name.'</a>’; } USE <a href=”https://wordpress.stackexchange.com/questions/247859/<?php catLink(1); ?>”> <?php … Read more

Get page content by category or tag

It sounds like you really need to be using posts for your content rather than pages since you want to organize your content into categories. You can use a page to display a custom page template (the Template Name: comment as shown below defines a new page template; that template will then be available as … Read more

Using URL parameters, list posts from category and custom taxonomy

In general circumstances, using URL parameters, you can list posts that belong to a specific category AND a custom taxonomy, like this: http://example.com/category/cars/?edition=usa Where, category is the Category base you are using for categories on your site (WordPress Dashboard > Settings > Permalinks > Category base); edition is the custom taxonomy’s base/slug; and usa is … Read more

Changing Top Level Items into Radio Buttons in the Categories Meta Box?

I’m pretty sure you could use JavaScript to do this for you very simply. I’d try this out: function convert_root_cats_to_radio() { global $post_type; if ( ‘post’ != $post_type ) return; ?> <script type=”text/javascript”> jQuery(“#categorychecklist>li>label input”).each(function(){ this.type=”radio”; }); </script> <?php } add_action( ‘admin_footer-post.php’, ‘convert_root_cats_to_radio’ ); add_action( ‘admin_footer-post-new.php’, ‘convert_root_cats_to_radio’ ); What this does is loops through the … Read more

Randomise results from a category page?

You can actually change any of the query parameters (like the order) by adding them to the url. For instance, the sample url below would randomize the posts on the category archive every time you refreshed, randomizing the results. http://sample.com/category/uncategorized/?orderby=rand Below is a basic form with the orderby value that would refresh whatever page/template it … Read more

Custom Nav Walker menu – Display category count

I think you should probably use wp_list_categories(), which even has parameters for a count, like e.g. show_count and pad_counts. Additionally it supports custom walkers via the walker parameter, but the walker would be based on Walker_Category – source -, which gives you every additional styling option you want.

Delete a specific category when deleting a user

delete_user action involves two parameters: $id and $reassign. So you should specify two parameters for the hook. Because sanitize_term() and sanitize_user() use different ways to sanitize strings, ‘tips_’ . $_POST[‘user_login’] and ‘tips_’ . $user_obj->user_login are not always the same string. So it’s better to use ‘tips_’ . sanitize_user($_POST[‘user_login’) as term name when inserting the term.

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