WordPress alphabetical A-Z custom post type post result display

Another option if you don’t want to hard-code the alphabet links (i.e., if no posts start with a letter, then that letter is not shown in pagination at all). // Always show pagination // First, grab all posts. $posts = get_posts(array( ‘numberposts’ => -1, ‘post_type’ => ‘homeless’, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’ )); // … Read more

Get category’s parent category while using get_the_category_list

get_the_category_list() returns a formatted list of category names, which does not (as you discovered) include the IDs. get_the_category(), by contrast, returns an array of WP Term objects. A WP Term object looks like this: [“term_id”]=> //int [“name”]=> //string [“slug”]=> //string [“term_group”]=> //int [“term_taxonomy_id”]=> //int [“taxonomy”]=> //string [“description”]=> //string [“parent”]=> //int [“count”]=> // int [“filter”]= //string … Read more

How to create a custom categories page

Here is a sample category.php template. You can place it in the main theme directory. <?php /** * A Simple Category Template */ get_header(); ?> <section id=”primary” class=”site-content”> <div id=”content” role=”main”> <?php // Check if there are any posts to display if (have_posts()) : ?> <header class=”archive-header”> <h1 class=”archive-title”>Category: <?php single_cat_title(”, false); ?></h1> <?php // … Read more

Can’t delete a category in WordPress

One of the categories is always set as the default category, which will be used for an article, if no other category is selected when the post is created. In your case it looks like Gallon tanks is the default one. You can change the default category from Dashboard > Settings > Writing > Default … Read more

wp_list_pages() exclude category

I think the solution that would work out best for you is just using your own query. Since you have modified pages to have categories and tags taxonomies wp_list_pages doesn’t support excluding the arguments quite like that. You could get an array of all page IDs that are assigned to each category, but you’d be … Read more

How to add custom color fields to the category edit page?

To add custom fields and save/update meta data to terms, you basically need to use these action hooks. custom fields html for new term {$taxonomy}_add_form_fields save custom field data for new term, get data from $_POST created_{$taxonomy} custom fields html for existing term {$taxonomy}_edit_form_fields save custom field data for existing term, get data from $_POST … Read more

how to wordpress When I click on the category link, subcategories appear

Here’s how you get all top-level categories and loop them to create a list of links, $parent_categories = get_categories( array( ‘fields’ => ‘id=>name’, // other term data no needed here ‘parent’ => 0, )); $parent_category_links = array(); foreach ($parent_categories as $parent_category_id => $parent_category_name) { $parent_category_links[] = sprintf( ‘<li><a href=”%s”>%s</a></li>’, esc_url( get_term_link( $parent_category_id, ‘category’ )), esc_html( … Read more

How to create a custom meta box field in category? [duplicate]

Simply add this code to functions.php file add_action ( ‘category_add_form_fields’, ‘___add_form_field_term_meta_text’ ); function ___add_form_field_term_meta_text() { ?> <div class=”form-field custom_image_upload”> <label for=”tag-description”>File Upload</label> <img src=”” style=”width:100px;height:100px;border:0;display:none;” /> <a title=”Set listing image” href=”javascript:;” id=”upload_listing_image_button” id=”set-listing-image” data-uploader_title=”Choose an image” data-uploader_button_text=”Set listing image”>Set listing image</a> <input type=”hidden” id=”upload_listing_image” name=”_listing_cover_image” value=”” /> </div> <?php } add_action ( ‘category_edit_form_fields’, ‘___edit_form_field_term_meta_text’ ); … Read more

How to show more than 5 posts of the category?

I hope you are talking about Learn More theme by Humble themes. Just downloaded this theme and checked source code. File get_posts.php has an argument, which returns only 5 posts. This file is located in theme folder: learnmore/inc/functions/get_posts.php $args = array( ‘orderby’ => get_theme_mod( ‘kb_article_orderby’, ‘date’ ), ‘order’ => get_theme_mod( ‘kb_article_order’, ‘ASC’ ), //here it … Read more