How to let users choose posts order in categories?

First in your category.php (depending on your theme files) add a simple form to let the user sort A-Z or Z-A: <form action=”” name=”custom_order” method=”POST”> <p> sort order: <select name=”CU_Order” id=”CU_Order”> <option value=”ASC”>A-Z</option> <option value=”DESC”>Z-A</option> </select> </p> <p> <input type=”hidden” name=”cs_action” value=”custom_sort_order”> <input type=”submit” name=”submit” value=”sort”> </p> </form> then using pre_get_posts hook you alter the … Read more

How to conditionally hide author name on Single.php if category is “news”, otherwise if category is something else display author name?

is_category returns true if the current page being viewed is a category term page (i.e. a list of posts belonging to some term) and false otherwise. So inside single.php it will always return false. If you want to check if a the current post in the Loop belongs to some category term, then you need … Read more

How to insert category list into post creation page, and retrieve chosen categories?

By default page post type doesn’t support category taxonomy. But you can easily fix it by register category taxonomy for page post type: add_action( ‘init’, ‘wpse8170_init’ ); function wpse8170_init() { register_taxonomy_for_object_type( ‘category’, ‘page’ ); } Now you will see categories meta box in the same place as you see it at post creation page. To … Read more

Get categories without post

Here is how you can list the empty cat’s this way can also refrence each category data like ID, Name etc $args = array( ‘hide_empty’ => 0, ‘pad_counts’ => true ); $categories = get_categories( $args ); foreach($categories as $category) { if($category->count == 0) { echo $category->name.”<br />”; } else { // do nothing } }

Category.php loads first before page.php?

WordPress select template, following its Template Hierarchy logic. What you have that is category archive, templates for individual pages are never considered for it. Also.. with the view of SEO, page.php is more important then category.php.. right? PHP template file is entirely back-end concepts, it doesn’t have anything to do with SEO inherently.

How can I change the tooltip in the_category?

I used this solution instead, within my single.php file: <?php //categories loop $categories = get_the_category(); $separator=”, “; $output=””; if($categories){ foreach($categories as $category) { $output .= ‘<a href=”‘.get_category_link( $category->term_id ).'” title=”‘ . esc_attr( sprintf( __( “%s” ), $category->name ) ) . ‘”>’.$category- >cat_name.'</a>’.$separator; } echo trim($output, $separator); } ?>