The 3rd parameter of has_term()
accepts a WP_Post or Post ID. Docs on has_term()
. In your example code, it would look like this:
<?php $postid = $_GET['post_id'];
if( has_term( 'campaign', 'type', $postid ) ): ?>
//Do something
<?php endif; ?>
Where campaign
would be the term, type
would be the taxonomy, and $postid
is the post that may have the campaign
term.
Related Posts:
- Best way to do multiple constructors in PHP
- Using register_activation_hook in classes
- Moving a PHP web-app to WordPress
- How to use multiple query with same meta key
- How to use WordPress (PHP) functions in AngularJS partials files?
- How to create a custom config file and get data using inline JS in a wordpress page
- How to Remove a Filter from the Admin List Table?
- Replacing the NavWalker dropdown element
- Remove commas from WooCommerce checkout addresses fields
- Concatenate site_url and string doesn’t work
- Getting the dropdown menu to redirect to different pages?
- enqueue multiple Google fonts with multiple weights and styles (italic)
- Get taxonomy terms only of the WP_Query current posts
- How to display user nickname (not display name) in PHP template?
- Extract subdomain and relative address from a url
- Custom Template 404 for specific custom post type
- Accessing site’s root from themes folder
- Random order of WP_Query results with highest meta value
- Different output from WP-CLI in bash vs PHP exec()
- How to style options page in dashboard?
- hook that when page is starting to load
- Theme Options Page – User Updates Logo
- How do I use this PHP library to access OpenGraph data in a child theme?
- Ajax category filtering products default show all
- How to exclude category ID from Looper in WordPress
- Custom user login page by creating a plugin
- Add a specific part of current category page url to shortcode
- Why ajax doesn’t work on certain wordpress hooks?
- Whitelisting items from custom options page
- Add_menu_page not displaying the menu in class based plugin
- Approve post and send the password
- multiple taxonomy select display only one in front end
- How to store options in an array
- Generate sidebar depending on height of post
- Get author and excerpt from URL
- Error using WordPress $wpdb object to get result from custom table
- Sidebar not appearing in footer, but it appears everywhere else!
- How to create table in wordpress without plugin? [closed]
- Why is my str_replace not working on short code submitted by front-end?
- Skip foreach loop
- How do you create two separate Register pages?
- $_GET[‘updated’] does not work in WordPress 3.1?
- In WordPress, how do I get the number of posts next to single_cat_title(”); in the category.php file?
- Include only posts with meta key “add_in_rss” in RSS Feed
- Need help with Code Correction php+wordpress
- SOAP Request/Parsing XML From wp_send_json_success
- List post by title length
- get db values for external js file
- How to exclude a widget from W3 Total Cache Plugin
- WordPress the_content Page Load
- WordPress -> If Is Role Subscriber Show Image?
- Using color schemes with Color Picker
- What should I write in the post action of this front end post form?
- How to split AJAX response into two divs
- Deleting expired session tokens in WordPress
- How to set variables with AJAX request to use in another function in WordPress
- Payment field disappears on custom Paypal plugin
- Creating a brand attribute as a variable
- Illegal string offset in PHP function in via Theme Customizer
- How to hide the file name of 404.php in URL?
- when hooking to pre_user_query my wordpress crashes when using very simple commands?
- Loop for recently (updated_post_meta) posts?
- I am having errors with checkout on wordpress
- Display articles with a different template in the home page | Solved |
- How to retrieve quantity input field by id in woocommerce
- How to use Multi SQL Database in WordPress?
- Help me understand how Search function works using dynamic_sidebar()
- How to display post meta bellow every posts
- Sudden Upload HTTP errors, PHP uploads and memory limits are already to high to my taste. Anything else?
- form submission reverts to index.php template
- Hide a specific category title from displaying on site
- How to change the structure/order of sections in a WordPress theme? [closed]
- Handling form actions in WordPress
- i want add conditional for add category in wordpress
- Return to the beginning of the results of a for loop
- Shortcode’s output to use as other shortcode’s parameter
- PHP code printed into CSS classes
- Thumbnail wouldn’t scale to size properly
- Scheduling a post using publish date from a custom field. Resulting post is set as published in the future instead of scheduled
- How to hook into the subscriber /wp-admin/index.php page?
- What syntax is this? “{{post.price}}”
- PHP script to redirect traffic based on website accessed
- How to remove title tag with this filter
- Real time notification on user profile after new comment
- How to handle the structure of page/taxonomy/post without making wordpress get confused with the url
- Add two or multiple functions in WordPress Post or Page
- Can’t put a hyperlink on Featured Post’s Image
- special characters not supporting in wordpress
- Custom user roles doesn’t apply changes
- How to get the first letter from custom field?
- Meta box not saving spaces
- A Space being added to url generated by custom plugin
- Why this plugin is not working?
- get_post_meta is always empty when I use wp_mail
- check if .min.css stylesheet exists
- How to execute add_action() function from custom plugin to Crontrol plugin or do_action()?
- Incomplete term slugs output from a foreach loop with get_the_terms
- Custom Shortcode with Dynamic Button
- Upgrade wordpress core programmatically with PHP [closed]
- Too many if’s and else if’s ?? – Must be better way [closed]