is_tag
checks whether the page being displayed is the tag archive page for the named tag. It does not check whether the post in a Loop has that tag, which is what you ask: “…to show if the post has tag premium…”. For that you need has_tag
if has_tag( 'premium' ){ ?>
<a href="https://wordpress.stackexchange.com/questions/125158/<?php the_permalink(); ?>" class="info"> Subscribe</a><?php
} else { ?>
<a href="https://wordpress.stackexchange.com/questions/125158/<?php the_permalink(); ?>" class="info">Read More</a><?php
}
Note that has_tag
requires the tag slug and not the tag name, hence the lowercase.
Related Posts:
- wp_enqueue_script adding conditional statement not working
- Check if first paragraph is an image, then show custom code right after it?
- If post author role is X
- Can a conditional statement apply to part of a slug?
- Add default content to posts in a specific category?
- is_front_page, is_page(‘slug’), is_page(id) not working
- Need help on creating If-statement for custom meta fields
- How to make gravatar.com avatars conditional?
- Loading Scripts on Specific Pages
- Condition function for is parent category?
- Conditional Statement – Best Way to Remove Nav on Contact Page
- Proper syntax for simple conditional bloginfo language
- wordpress is_page() problem
- Location-Based Content
- Personalized message for each unique password-protected page
- Conditional Shortcode image display
- Change Woocommerce order button page on particular page
- Change a url / link if a user is logged in?
- to create own conditional tags for business directory in wp
- How to use “Cases” instead of “IFs” for conditional logic
- Which is the better way to write a conditional statement? [closed]
- Nested conditionals
- Is there a way to password-protect part of a post?
- if/Else have_posts Else fails to echo message to page
- Conditonal statement for iPad
- Return function only on certain pages
- Conditional for Custom Post Types
- Date-Based Conditional Tag
- Message box when accessed from iPad
- Show this code if user has previously left a comment
- Insert a conditional in the middle of a function to give it 2 different outcomes
- How can I use ‘edit_form_after_title’ conditionally?
- Force Log in to view a page
- Conditional loading of CSS for my plugin
- Looks like this if condition is not working [closed]
- Generating images from an array of categories
- WP conditional site logo and header block
- How to know if the most recent article
- Widget logic conditional widget
- How to display image on condition that a selection has been made
- How to Conditionally Not Display a Link Based on Current URL?
- Allow users to only CREATE one single (custom) post
- If statement to check for post_content
- why is my custom loop failing?
- Conditional sidebar menu
- What is the best way to disable my WP website if the user has adblocker on? [closed]
- How can I determine if a post has an image attachment?
- If Post Type equals, then display X content
- Multisite Conditional (if blog_id?) in a page template?
- Loading Javascript Only When Specific Content Existing in a Post?
- Shortcode to Gutenberg-block: additional text on front-end and conditional display
- Conditional Statement – check if post has an attachment image
- Is there a PHP function that can match anything after the given URL, so my IF statement will work in each instance?
- Trying to use Ternary operators with WP Conditionals
- Performance-wise, is it better to enqueue a (small) script on every page or test to see if it’s needed?
- how to know if the post has pagination () or not
- Conditionally load CSS/JS/PHP in wp-admin if using a mobile device
- can’t use the page_test method to check pagination
- Conditional for 404 page not work
- If Specific Post, Link Elsewhere
- Conditional PNG Overlay in Custom Post Type Loop Depending on Post Type
- Change content of page in child theme using plugin
- Redirect to a different page through registration, depending on page
- What is the correct way to write this conditional statement?
- Displaying a widget in sidebar only when no other widgets rendered?
- Reordering Buddy Press profile navigation [closed]
- Search filter triggered & sort by custom post type
- Changing select options based on previous select with PHP & AJAX
- Advanced Custom Fields – display label and value only if value entered
- Specific coditional usage [closed]
- Only on single post page
- Check IF single OR multiple custom data has been entered
- Problems with my conditionals in single.php by category
- If have posts a week old, display, else display a different loop
- Target pages using a specific page template
- How to make widget appear conditionally
- How to make a conditional statement within $output in shortcodes.php?
- Conditional function for excluding first image from content, not working
- include content within conditional statement?
- Using conditional statements in place of custom Page templates
- Show label for value only when value exists, basic php
- Return count for characters in the comment and perform action based on the length
- Getting false for is_home() on Posts page
- Target a page with query
- Custom wp_query inside a conditional stament inside a template part doesn’t work: why?
- Loading a stylesheet conditionally & verifying CSS
- Using Switch Statement to Change Image According to Last Digit of Topic ID
- If else statement based on referral URL
- Whats a good strategy for localising WordPress post and page content?
- Conditional loop based on current page
- Conditional statements based on custom meta value in category archives
- Display WP Start bar on front page only
- restrict access to specific urls on a specific period of time
- Using conditionals, maybe from a DB, to register & enqueue files, for varying pages, in functions.php
- Php markup question: php/html within conditional bit
- Custom Meta Box If Else Statement
- ACF loops false value with repeater and checkbox
- Not able to see the error [closed]
- check if post is set to “password protected”
- Conditional display based on ACF checkbox