WordPress has no conditional for substring testing but you can do this using PHPs built-in function: strpos()
global $post;
if( false !== strpos( $post->post_name, 'beef' ) ) {
// Do Things
}
The above returns true if beef
is found somewhere in the post slug.
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
- 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
- How to write this conditional statement?
- 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]
- wp enqueue style on specific page templates
- Loading scripts only if a particular shortcode or widget is present
- how to test for attached image
- Show different different menu in theme_location depending on x
- meta content on required pages
- How Can I Register Menus and Widgets Conditionally Based on Theme Options/Settings?
- Conditional Ajax inclusion
- Search result conditonal tag
- functions.php conditional tag – only show in single.php?
- How to Add Javascript Only When a Function Exists?
- How do display simple page for printing product info? [closed]
- Duplicating Table of Contents for Paginated Post
- How to not show post_thumbnail from specific category for not logged users
- Conditional display for custom fields/taxonomy
- WP for main site and two blogs – implementation
- Cluster WooCommerce products in each Category Archive by Tags assigned to products
- Creating conditional to display taxonomy term meta
- Is_front_page inside header.php is always returning true
- Adding a template part as part of a shortcode
- is_main_site() Always Returns True
- PHP conditional script issue
- Conditionals if tags exist?
- Where do you add code in custom fuctions so it works on a specific page?
- If user is logged in and has a role echo statement
- Banner appearing on Pages but not Posts; call it conditional confusion
- If custom taxonomy else conditional [closed]
- Why is the `if else` not working?
- How do I test whether [gallery] is empty?
- Do not run this code on posts with a specific tag!
- How to display conditional menus with Twenty-twenty two theme (and other new block themes)?
- can you help review CCCP (Conditional Cookie Content Post) and help to create a block?
- How do I make content only load on desktop? [duplicate]
- Change Login or Logout text based on status
- choose selected for select option with condition [closed]
- Modify wp-login.php Labels Conditionally Based On Referring URL
- Show code only on WooCommerce Pages
- Conditional Fields depending on checkboxes
- Conditional: IF current author’s custom post has a post thumbnail
- Understanding and using did_action() in a conditional statement
- Display content based on Author Custom Post type
- Different titles for static, posts, and every xy page
- If Month=Particular month display content [closed]
- Php conditional help needed
- functions.php conditional output for a single plugin
- How do I add a nested conditional within an echo – to use a default image if there isn’t one in the post?
- Template tag for /page/# structure
- Create citation and url in post using 3 custom fields with conditions for each field… So close!
- Loop to pull content from parent element in custom post type [duplicate]
- Hide a nav menu item based on get_user_meta results
- A conditional button
- Weird html output of single_cat_title – is not inside of the html element?
- How to set up a echo? [closed]
- Dynamic Buttons According to URL parameter
- How can i hide a specific class when cart subtotal is above a certain amount