Try to use get_term_by()
, where first argument is a field, in your case – name. Second is your value. I used esc_attr()
to make it secure. Third one is taxonomy, as example I put here category
.
if ($_SERVER["REQUEST_METHOD"] == "GET" && $_GET['fname2'] && $_GET['fname']) {
$nameb = get_term_by('name', esc_attr($_GET['fname2']), 'category');
$namea = get_term_by('name', esc_attr($_GET['fname']), 'category');
}
//check if there is an objects
if( $nameb instanceof WP_Term && $nameb instanceof WP_Term ){
echo $nameb->term_id;
echo $namea->name;
}
Reference with some examples – here
Returned object:
(object) array(
'term_id' => 49,
'name' => 'Term Name',
'slug' => 'term-name',
'term_group' => 0,
'term_taxonomy_id' => 49,
'taxonomy' => 'category',
'description' => '',
'parent' => 0,
'count' => 286,
'filter' => 'raw',
)
Related Posts:
- Show posts without term
- List taxonomy terms plus their latest post ordered by post date
- Get array of current post term ID’s
- Function get_queried_object() return NULL in custom taxonomy
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- List custom taxonomy terms sharing posts with a term from a second custom taxonomy
- WordPress query with items from more than one selfdefined taxonomy as `term` argument
- Filter Custom Taxonomy Posts
- How to add custom meta to ‘pre_get_terms’?
- WP_Query to output chosen term and posts with no term assigned
- WP Job Manager plugin – Listing only the twelve job categories on frontpage order by jobs they have
- How to print term name inside wp post loop
- Check if a post has term inside loop
- Only show tag with the same id as the post
- display ACF repater field in archive page
- How to define a custom hierarchy for terms?
- taxonomy-{term}.php terms pagination returning 404 after a certain page
- WordPress tax_query “and” operator not functioning as desired
- Custom taxonomy query broken after upgrade to 4.4
- How to add taxonomy filter on the query fly?
- Query two taxonomies via URL or link?
- Get All IDs Of A Post Type Using WP_Query
- Get list of posts which have at least one term from a custom taxonomy with WP_Query
- Counting number of posts with Category B in Category A
- Select posts wich has no relationship in custom taxonomy
- Get random terms
- WP Query for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)
- Filter and list posts of a custom taxonomy
- WP_Query use for a filter with multiple Taxonomies and Terms
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- How to get user_id from wordpress database inside ajax function?
- Display link to taxonomy archive only if it has posts with certain custom field values
- Pass array of taxonomy terms to wp_query
- Get list of terms that have posts in another term
- Formulate a url to show posts with both taxonomy terms
- Query with custom taxonomy not working
- Taxonomy search/filter with multiple taxonomies and multiple taxonomy terms
- Order by slug in get_terms with multiple taxonomies
- WordPress Related Post by tags in Single.php
- Filtering WP_Query Dynamically on the Front-End
- Return Taxonomy/Term Information with Posts (WP_Query/get_posts)
- Query custom post type by custom taxonomy (category slug)
- How to Filter Posts by Custom Fields?
- WordPress loop: Show only a Custom Post Type Taxononmy TERM
- WP_Query ignoring tax_query when is_singular
- wp_query for multiple cities (multiple values in a metabox)
- How to order posts by title after they have already been sorted by category
- Search form not working with custom query?
- Post loop for all taxonomy terms
- Get posts by list of post IDs ordered by those IDs?
- Taxonomy order exception for specific term
- WP_Query args to show posts from specific custom taxonomy
- Using custom taxonomies in a query
- get_the_terms – but only show 4 Posts
- Count posts per taxonomy else change taxonomy if less than x number
- Custom Taxonomy Breaks Pages
- Wp_query…a type of term a different div
- Compare “Main” post ID to ID inside wp_query loop
- Display posts from an array of ID’s
- Can’t get term id for category archive
- How can I do a orderby by the number of items? So basically list by starting with the array with the largest number of post
- How to make a post with certain taxonomy term display first before other post with only one query?
- wp-query and wp_get_post_terms on custom taxonomy archive page
- Show X taxonomies of the latest published posts
- How to _GET multiple value checkbox WP_Query in Custom Toxonomy / Custom Fields
- display post count in archive page that have relation with another taxonomy term
- Save queried result into database
- Custom Taxonomy – Modify Function to Get Child Category
- wp_set_object_terms() custom taxonomy not working correctly when using insert post
- Get categories within specific term
- How to display Woocommerce products list by tag
- Only return taxonomies that are linked to a category & product
- Query WP Posts, then list the taxonomies from those posts
- Displaying Pages in Nav Sub-Menu with Specific Taxonomy Terms?
- Optimal way to make tags in tax_query optional?
- Taxonomy Terms That Don’t Exist Display Results
- Adding additional taxonomies to wordpress taxonomy page
- How to create page that lists tags by initial letter?
- How can I get all the posts that are related with a specific taxonomy term?
- Query Top Set Custom Taxonomy In Given Timeperiod
- tax_query not working for taxonomy slug
- Get posts of an specific term of a custom taxonomy
- Rewrite rule pagination on different url levels
- Select posts wich has no relationship in custom taxonomy
- How to get hierarchical number of custom taxanomy
- WP_Query to show post from a category OR custom field – Not 100% answered
- Get newest value of an array
- Add a custom variable to query page object
- Filter custom post type by custom taxomony
- Page displaying 1st post from a range of custom tax?
- WordPress WP_Query Array Custom search via taxonomies
- query_posts problem – need help
- WP_Query and DES sort for Custom Taxonomy based upon a meta field?
- tax_query not working properly with get_posts
- query only direct child and sub-terms of a current term archive
- Get access to all terms associated to each post that the wp_query loop displays
- How can I get taxonomy term name using term slug & post ID using build in WordPress function or class?
- Give attachments an archive page, and exclude unattached ones
- I’m trying to get posts under a custom taxonomy but I don’t know what I’m doing wrong here
- Display Featured image from custom post type category (custom taxonomy) wise