You can try modifying your code as follows to correctly bold email addresses in job listings:
function bold_emails_in_job_listings($content) {
if (is_singular('job_listing')) {
$content = preg_replace_callback('/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/', function($matches) {
return '<strong>' . $matches[0] . '</strong>';
}, $content);
}
return $content;
}
add_filter('the_content', 'bold_emails_in_job_listings');
The change I made is in the regular expression pattern. I replaced [A-Z|a-z]
with [A-Za-z]
to correctly match email addresses in both uppercase and lowercase letters. This should make your function work as expected, and it will bold email addresses in job listings.
Related Posts:
- the_date() not working
- What is the best php version to use with WordPress?
- WP-API v2 Custom Endpoint Response Formatting
- How to call a function only once (global variable scope)
- Multiple is_page() in page.php
- Get author full name
- How to make WordPress plugin check for database changes and then do something?
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- Extract the first oembed url inserted on the content of a post
- WP API V2 returning Invalid User ID
- Limit the_excerpt with max of x characters
- How can update custom meta for all posts
- wp_get_attachment_url filter won’t accept two arguments
- Am I not understanding plugins?
- Passing the page ID to a login php script
- PHP/MySQL issues when running WP on EC2 cloud [closed]
- wrong php date()?
- It is a good idea to store values from the global $post if they are used multiple times?
- How do I fetch all comments per post via WP REST API?
- Vagrantpress + composer
- esc_url returns incorrect URL
- Using More Tag in Combination with the_excerpt
- combine Code 1 with Code 2
- Recent posts with featured image or fallback image with permalink
- Custom Form Processing Issue
- Custom theme: Alternatives to long list of ‘include’ in functions.php
- Reordering Buddy Press profile navigation [closed]
- How to sanitize any integer input field in wordpress?
- How can I get the total number of installed importers?
- wpdb php get_var query to get ID for URL image doesn’t work for ID over 999
- Change title only in dynamic page
- How to make products with no cost in WooCommerce
- Query Pages and post excerpts dynamically
- two columns of posts on homepage, one of them “favorites”
- Help with .htaccess and Login with Subfolders
- Catchable fatal error on 3.6 update
- AJAX – Returning Two JSON Objects with One PHP Function
- Parse error: syntax error, unexpected ‘}’ on get_the_author_meta [closed]
- Can’t Query Custom Table Using $wpdb Method
- How can I access string value in an array?
- Defined WordPress Memory Limit to Unlimited
- Update postmeta after theme switch
- WordPress gallery shortag
- Set site title & tagline with wp.config or function.php
- Shortcode to embed Edit Account form not working
- Errors after upgrading PHP to 7.4 WordPress
- Get user custom field value on function.php
- WooCommerce – Moving Product Price to the Left of Add to Cart Button [closed]
- How Do I Find & Remove H1 From Site-Title-Wrapper? [closed]
- How to make a conditional statement within $output in shortcodes.php?
- Dynamically Generate Functions and Hooks
- PHP if have image display image, if else text
- Covert WordPress Blogname into JQuery
- displaying a fall back query if there’s nothing in the post-type category
- need help adding a new sidebar to a page that can’t use page-templates -> multisite
- How to list users like an archive page 10 users on page and have navigations
- WordPressUser Submission Form
- Strip from or something better?
- how to add datas in taxonomy to post with wp_insert_post
- Add custom fields from different posts
- How do you get the current post taxonomy so I can get the current post taxonomy? into a variable to THEN loop through all post with that taxonomy.,
- Remove an action created by a Gravity Forms add-on
- Displaying the Archive Page’s Name on the Page
- Adding HTML Code to Replace Text in PHP
- Get nice name of category from slug (remove dashes of category)
- How to disable PHP functions in WordPress?
- switch_to_blog() + do_action(‘generate_footer’) not working in multisite
- Posts missing on author page
- How do I add a predefined class to a custom html element?
- Display post date also if the date it’s the same for each post
- How to access this jQuery/AJAX data in a PHP file/WordPress plugin
- Woocommerce – if selected attribute term equals
- split 1 cart item into instock and back ordered
- Display page content in different sections – based on page break block?
- WP Error using wp_insert_term
- Collapsible menu on post sidebar only expands and does not collapse
- Add class to all meta boxes for a custom post type
- How to trim content AND retain HTML?
- Adding users to another blog
- Display posts using post ID’s in an array
- 403 Forbidden Localhost Wamp Apache Php
- Override 404 when navigating to single php file
- I’m writing my first plugin and my echo output is showing up on every page of my wordpress installation
- Beyond widget side menu editing, with the php page, custom template
- wp_delete_comment is doing nothing
- Adding a “Word” in php code
- conditionally load a default static image if image metabox has no value
- How to add a code for lastpostdate after/inside a specific menu link?
- Let users register weight each day and save it in DB
- Adding code to the function file
- Query specific posts per user selections from dropdown menus
- why my “recepie” category is not taken into account in my request
- How to show blog posts changing every time after refreshing the page in non-wordpress website?
- php 7.0 update to 7.1 and at least 7.2
- Execute multiple PHP Snippets causes error?
- Social Sharing Buttons in Recent Articles List
- Preventing script injections in HTML form
- How to add a php package to an existing wordpress website
- How to access admin menu labels and links on front-end?
- Editing stylehseet url in head section of WordPress