get_categories() does not require parameters, by default it will query the post type post
and the taxonomy category
. However, get_terms() require a taxonomy parameter.
Also, in the second function, you wrote:
$categories = get_terms();
It should have been
$terms = get_terms('your_taxonomy');
Related Posts:
- Isotope Drop Down Categories Filter Function
- Hierarchical taxonomy list with modificated term links
- wp_set_object_terms and arrays
- How to find objects by terms
- Counting number of posts in a category and its sub categories and displaying result using shortcode
- Display certain amount of posts on taxonomy archive page
- category not display in word press grammatically
- How do I get taxonomy terms by ID in a specific order
- Problems with function on function.php
- Check if term object is in array
- Get taxonomy terms only of the WP_Query current posts
- get_the_terms – only top level
- Query all posts of a custom taxonomy term
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- get a simple array of all of the term names that exist in all taxonomies
- Get term siblings of current child taxonomy
- How to get post’s current parent term ID?
- register_taxonomy() take much queries
- List taxonomy term slugs within shortcode (do_shortcode)
- Copy taxonomy terms from one post to another programmatically
- Limit Taxonomy Output in Conditional Statement
- Hide image if taxonomy term is empty
- How to filter custom taxonomy term name, slug, and description?
- change the default order of posts only for specific categories
- Exclude product attributes from taxonomy terms loop
- Trying to display terms from custom taxonomy within function
- How to change the author box selection on a post to a custom taxonomy
- How to hide a child category and show his parent category
- How do I edit the terms output args or array data?
- update_term_meta() only updating once on certain meta keys
- How to sort (orderby) a query done by a template function before the ‘foreach’ loop?
- New term taxonomy and description in front page. Input’s
- How to display terms from two taxonomies in one php code?
- Custom Taxonomy as Link
- Get all the contents of taxonomy and sort by term
- category & sub category order issues in wordpress
- How to extract URLs from wordpress taxonomies
- WordPress different custom tag being displayed in on tag list
- WordPress taxonomy and terms question
- PHP code in page template vs functions
- Apply class to every paragraph that holds image?
- username_exists() function can’t be access without logging in
- Inserting Gravity Form checkbox values into Advanced Custom Fields [closed]
- Check if page parent has certain template
- Delete post revisions on post publish
- How to get the term before the last from a custom taxonomy?
- How do I list the_tags() into HTML data-attribute
- WordPress if (is_page) translation on certain page
- Highlight Current Tag in wp_tag_cloud
- Getting rid of role=”navigation” in the Home Page Pagination
- How to use return in my custom function instead of echo
- Get first URL from post content
- Setting custom canonical urls
- Trigger popup in a php if/else statement
- Setting a cookie upon specific URL visit
- get post based on category chosen in drop down – The ajax method
- how to make separate field in wordpress user_data_
- How to output a PHP file values by shortcode?
- get_term_link() returns correct – But illogical error-messages disturb
- Set the background to a default image if there isn’t a specified “featured image”
- WordPress Access allowed to fewer pages till user logs in
- different id for same element visual composer [closed]
- Tax query in pre_get_posts not working
- 3 Slashes appear after Apostrophe in custom fields after updating product-site
- Trying to retrieve post meta
- Need help enqueueing webfonts
- How to remove ?p= from wordpress short links
- Add class to website based on post taxonomy
- Need php code’s output to display underneath a Divi Module
- WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
- How to make function appear in sentence?
- How to define a variable already defined in a plugin function?
- woocommerce specific quantities for product
- Custom query vars filters problem with pagination
- Change header on pages displaying taxonomy items
- Query for user roles
- Use SCSSPHP to compile Theme Customizer Values into .SCSS files ready to compile to CSS
- Must filter functions receive all arguments passed to them?
- Displaying Slider in Front Page (home) using Customizr Theme
- Is there a way to create a “copy post” link?
- Taxonomy term description with style, only if the description exists?
- PHP displaying wrong custom taxonomy images
- Use of antispambot with $curauth->email
- Restrict post to current user in postmeta
- copy fields value to another field
- posts_per_page displays only 2 posts instead of 4 posts
- Get parent category name when only child category is applied to a product
- Can an AJAX callback function access a PHP variable which was defined during initial page load?
- Adding product permalink on admin order page throwing error
- Before & After Content – After Content directly below Before Content when using require_once
- How to redirect (301) trashed post to it’s parent taxonomy TERM ARCHIVE instead of 404 page
- How to call WordPress PHP file using external js file
- use system script advertising in wordpress multisite
- Use WP_Query Data In Cookie
- Change taxonomy for categories
- Insert wordpress tags below posts via functions.php
- Help with my first Metabox helper class
- static array on functions.php
- Integrating CSS Into a WP Function Call [closed]
- Change background image based on tags