Try this,
$cat = get_category_by_path('http://www.example.com/category/category-name/')
Reference http://codex.wordpress.org/Function_Reference/get_category_by_path
Related Posts:
- Custom plugin: Trying to show saved data on frontend
- Is there a browser plugin or method to find which php template an item is coming from?
- Display message once per session to users with a specific role
- How to correct schedule my event weekly with wp_schedule_event()
- How can I add a class to a single menu item?
- WordPress returns a wrong date
- How to enlarge the media file upload size in wordpress admin
- How do I hardcode a WordPress shortcode into my theme?
- WPDB: how to get the value of a field in a custom database table
- Debugging PHP object during Ajax call in WordPress
- How to exclude specific category from the get_the_category(); array
- Memory errors with media upload, WordPress can’t use more than 96M (while there’s 512 available!)
- WordPress override bloginfo variable
- How do I display a user’s previous orders as a select box option on a product?
- Hide wordpress field if data is empty in post!
- Show MySQL errors that occur when I excute $wpdb->insert()
- Echo a hierarchical list of post data from custom fields
- The text box have space character
- get_the_tags() not iterating through for/while loop, but will with foreach
- Is there an error in my code?
- Show categories then when clicked on a category list all sub category and when clicked show all posts in that sub category
- Iterate through posts based on array of categories
- How to disable server signature on wordpress? [closed]
- Custom query, checking values of multiple meta keys
- How do I remove the product thumbnail link from a specific div in Woocommerce? [closed]
- wp attempt focus, disabling without touching core
- Genesis framework comments broken?
- How can I edit the content in index.php? [duplicate]
- How to know where this function definition is declared?
- Is this spyware on my site or a real Java update?
- Shortcode from a function not working
- How to make an embeded a Youtube video from custom field text responsive to screen size?
- Is it best to avoid using $wpdb for security issues?
- How to add text to the start of all comments?
- If else statement to check for thumbnail and whether or not it’s a mobile device – streamline
- How can I automatically resize up images to fit into all of my registered image sizes
- How can I use a sliced image As banner? [closed]
- Compare $_POST returned values with term array
- Correct PHP to output a single result of a Function with SQL Query
- How to remove the h6 tag for the entry-category Class
- Broken kses.php function “wp_kses_named_entities” crashes WordPress
- Understanding webhooks
- if custom field doesn’t exist, use post thumbnail instead, as image background
- Display child page content of a specific parent on home page
- Processing ajax call to php to insert into mysql database
- How to add 3 weeks to the_time() function
- wp nav menu: show submenu below li item
- Show different size featured images (the_post_thumbnail) for 1st, 2nd and 3rd posts?
- Pagination stays on same page for post category
- Show label for value only when value exists, basic php
- WordPress Custom Query: Combining Two Functions
- Counting number of posts in multiple (sub)categories using shortcode
- Display WordPress search results based on the selected Sub-Category
- Reject all malicious URL requests functions.php
- Using some Loop or repeatable fucntion in AJAX and PHP to reduce repeatability
- How do I call a value from the datase using ajax
- Woocommerce disable order item link (backend) [closed]
- Create an array with all the links of the years’ archive (of a custom post type)
- Where to add my PHP codes for AJAX Jquery to work?
- Display the list of user’s comments + the post title + date
- Adding ELSE argument to AJAX Live Search for “No results found”
- get_results() doesn’t fetch the result
- Is it possible to change the get_posts() or wp_query() function to alter the results that are returned?
- How to optimize and reduce excessive database queries
- Comparison operator != not working in field [closed]
- Notice: Undefined variable
- PHP 7.2.18 | Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- How to override WooCommerce Order Item Meta with data from Cart?
- How can i style “echo apply_filters”
- get_category_parents to array
- Meta query not showing result properly
- How to properly create multiple conditions to redirect users roles to different pages
- unable to add category in creating post dynamically
- How does WordPress rewrite URLS using its PHP scripts
- making a search.php query
- Splitting table data to pages with numbers
- How do I generate formatted permalinks as specified in backend options?
- Upload images from one server to an other in wordpress
- List all blogs apart from the current blog and main blog in WordPress Multisite
- Ajax not updating to database
- Custom YouTube Plugin loading different PHP library on live site and localhost
- Issue in url update when using wordpress update query
- Widget edit and add in any page
- How to use Amazon Elastic Transcoder from WordPress using AWS SDK for PHP?
- Headers Already Sent
- Sum of Custom Meta written by Authour
- Active class not working on custom menu link using add_menu_page
- If or/and statement advanced custom fields [closed]
- Remove duplicates from foreach
- Show items by user_role
- Determine if only one image attached to a post/page
- link to page_for_posts
- wp_mail vs mail functions and header arrays
- WordPress get_the_term_list include class name for heirachy
- WooCommerce – Show ‘Sales’ badge on variable products where only some variations have sales price [closed]
- Add default block css when the block has been added with php?
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- Custom Post Type doesn’t have template content when creating programmatically in PHP but does when created in WP Admin
- how can i link threejs in my functions.php file in understrap theme
- WordPress / PHP: Check if column has value and then check if value in array