Found a solution.
I found a function that answered my question.
Here is the function:
function get_category_by_letter($letter) {
$args=array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0);
$categories=get_categories($args);
foreach($categories as $category) {
$catname = $category->name;
$first_letter = substr(strip_tags($catname), 0 , 1);
if(strcasecmp($first_letter,$letter) != 0) continue;
else {
$cats[] = $category->term_id;
$cats[] = $category->name;
}
}
return $cats;
}
Related Posts:
- Only one category per post
- How to get permalinks with category base working with sub-categories
- WP 3.9 TinyMCE no longer loads on category description editor
- Change Gutenberg category checkboxes to radios
- Checklist of selected categories
- Exclude categories from search query
- Why is per_page not working with categories in WP API?
- How to order the get_categories result
- List posts by category exclude current post
- How can I calculate the total number of categories at different hierarchy levels?
- In the tag archive – display count of posts for each category they belong to
- How to add a background image to category and display image on category page
- Display only deepest category on a single post?
- How we add new categories by wp_insert_post
- Listing all posts from current category on page
- Hide uncategorized products from the shop page
- I want exclude the particular category in sidebar
- wp_list_categories() – adding a div to each li?
- Listing Parent, Child and GrandChild Categories and then the PostTitles on Page Template !
- How Can You Exclude Categories From Your RSS Feeds?
- Help with multiple dropdown tags search
- How to get category URL with the slug?
- weekly archive for custom category
- ?cat=-1 Indexed Versions Of Homepage
- .htaccess too many redirects based on category slug
- How get permalink for the current category or tag?
- using checked function to verify value against an array
- wp_list_categories depth and number
- Category index featured image
- Order categories by most posts
- need to add custom field in more products
- How to redefine the sorting of product categories by menu_order?
- Custom archive.php: retrieve right post categories?
- Add category only if post has custom taxonomy category
- Restrict author to create subcategory in a selected category
- Get posts from 2 different categories
- categories on attachment page
- A single category with a specific permalink structure differing from the standard set for the rest of the site
- List only child categories within posts
- Random Featured Image Based on Category
- How to restrict user to choose 1 category for a post
- Failing in_category or has_category in the_content_feed
- Show Pages in Categories
- get_posts ignoring ‘category’ and displaying all posts
- How to change the thumbnail size to a specific category?
- Get paged category link programmatically
- Function to automatically rename the base category permalink
- Add theme-color meta tag to head?
- How to get an array with all categories and corresponding names?
- Is it possible to have a template that works on multiple categories where the link address contains the specific category?
- WordPress Customizer: Dropdown with Category output
- Custom tax_query filter not working for Woocommerce product categories
- display a link to all the categories of current post, including parents
- How do order product categories – on a parent category page – in Woocommerce?
- Display only subcategories of a category and not sub-subcategories
- category link not working for a specific slug, works for others
- Shows only one Category in home page
- Get categories list with category name in custom WP_List_Table class
- Exclude the category in WordPress
- How to automatically generate custom menu item from categories?
- How do I remove pagination from just some Categories?
- Categories not posts at the frontpage
- Using custom structure prefix showing 404 for sub-categories
- Conditional label Woocommerce archive [unsolved]
- How can i change sort category view starting from child then parent, not alphabetically
- Products category search not working
- how tho change number of posts in loop from specific categories
- Showing the category hierarchy as clicked in WordPress, with image and desc
- error in specific category loop
- WordPress category title not update in navigation menu
- Posts says they are uncategorized but they are not
- How to call Primary Category for WordPress Woocommerce
- Meta Box: display single image on an archive-template
- I just want to list ONLY the child categories, but not grandchildren
- Search Replace Database ONLY for posts of certain category?
- Categories Help and video uploads
- Display only children of custom hierachial taxonomy
- Read More showing only on first post
- Filtered post assigned to categories
- Paginations in Category Page Leads to Sample Pages
- Allow a user to ‘subscribe’ to different post categories?
- How to exclude a specific categogy from a custom page template
- If on Category Page add “active” class?
- Transfering static site to wordpress and retaining category by month paginations
- Category Templates for Post Types not Working
- Change category base based on category
- Show only one category in main query, issues on tag page
- Bringing Ajax Loading Feature on Category Pages
- Need help with category page customization meeting certain condition
- Show category-ID in custom category-list
- Dynamically Adding Category Specific Content To Specific Category & Subcategory Pages
- Structure with category setting
- Do not show all post from all categories, just show posts from category in current loop
- How to prevent page re-sizing for mobile browsers [closed]
- How to get specific number of category post on a page or category page?
- Use same wordpress category base and tags as the prefix as the post permalink
- Display different sidebar based on search results from one category
- Adding category to existing post (uploaded file)
- how to create a page that shows all of multiple category posts on a single page
- Quick Edit on taxonomy names results in error