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
- Put ACF function output code the_terms
- 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
- Include a file that has a function in it
- Execute Jquery when a specific page in my plugin is loading
- How to get all the items of a taxonomy even if it does not have a custom post type?
- Conditional On custom field plugin metabox
- get_template_part function and add images
- Displaying Slider in Front Page (home) using Customizr Theme
- How can I assign separate stylesheets to different pages?
- Need advice on theme customizer and child themes
- How to make sure relative URL works when site is not on root domain?
- How to add PHP pagination to wordpress
- How to pass hook variable to function?
- WordPress custom taxonomy
- Remove submenu item from list
- Get the alt text of the image in a array
- How to prevent a function from running based on host (ie web vs local)?
- Filter unique custom field value based on custom taxonomy category or other custom field
- call a string/function from database
- How to call custom function outside from the admin page?
- making php value numeric
- Strip from or something better?
- Add a select-option to the default widgets
- How to break up php code to avoid echo
- Woocommerce getting top level category parent and make all sub categories have the same template and menu
- Defining multiple categories for showing latest posts
- the_post_thumbnail issues
- Is there a way to create a “copy post” link?
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- Display additional page templates and a sidebar on plugin activation
- Dynamic Menu drops pages?
- Adding a ‘style=’ bit to image_send_to_editor output
- Post Views Code Hacks
- Closing WP_LINK_PAGES DIV ID w/After Argmuent
- Aspx/Rss feed – failed to open stream: Redirection limit reached
- Adding an Unlinked Space in a Custom Function
- exclude custom post type from running a function
- Taxonomy term description with style, only if the description exists?
- Exclude function from running on a certain page
- PHP displaying wrong custom taxonomy images
- Convert all uploaded PNG files to PNG-8 format
- AJAX function not working [closed]
- Migrating site, only header shows
- Customize field names in backend profile edit page through function.php [duplicate]
- Make table disappear when fields are left blank?
- Menu not styling. New menus functionality giving me a headache
- Get date function not working
- Pagination Not Working (pages duplicating content)
- Use of antispambot with $curauth->email
- Auto create Nextgen Gallery on post creation [closed]
- Uses for function: wp_update_user
- How do I call an external php non WordPress class into functions.php?
- Insert content into head tag with function
- Function to call either single post or category
- Custom functions for string data calculations
- How are these PHP functions applied to a specific page in WordPress?
- WP insert post Redirect after function has executed
- SQL error with custom query
- The additional fee for the COD payment method not visible in the front-end
- Hide media for non logged in users
- Programmatically revert to backup .htaccess a possibility?
- PHP identify duplicate words in a text string against a list of words