You need to use get_field
function here instead of the_field
.
function wrapImagesInDiv($content) {
if ( in_category( 'projects' ) ) {
$pattern = '/(<img[^>]*class=\"([^>]*?)\"[^>]*>)/i';
$replacement="
<div class="owl-wrapper">
<div class="owl-item $2">
".get_field('description').'
$1
</div>
</div>';
$content = preg_replace($pattern, $replacement, $content);
}
return $content;
}
add_filter('the_content', 'wrapImagesInDiv');
Function get_field
returns the value but the_field
prints the value.
Related Posts:
- Add multiple custom fields to the general settings page
- When should you, and when should you not, use wp_list_pluck()?
- Display random categories on the front page (Finding and Editing Theme Functions)
- functions.php inject inline css
- Is it possible to remove the “standard” post format?
- Woocommerce add to simple product attribute programmatically [closed]
- Issue with get_theme_mod returning a blank value instead of the saved value
- How to remove row-actions from pages table?
- opening links in new tab using – add_filter( ‘the_content’, ‘make_clickable’);
- Modify search function in WordPress (TwentyTwelve)
- Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
- How to customize search result page title?
- Auto delete WordPress images/thumbnails (all sizes) and featured after X days/hours, or similar?
- How to fix a theme with page.php Default Template that accidentally deleted?
- Removing Unnecessary Text from Admin Menu without CSS
- Set default options for inserting media
- Default or Preset Content for Custom Post Types
- Remove tag on my RSS Feed
- Display WordPress Search
- How do I change parameters without changing the core
- Functions.php: If its single?
- Problem with extract() with custom shortcode
- How to add a rel attribute to images that contains their categories?
- add sidebar area to header of child theme
- Preferred Use of home_url()?
- Custom function for user register in wp?
- Best way to programatically add “rel” attributes to page and post images
- Theme-Config tab in admin Pannel?
- Creating loop within functions.php
- How to Add a Random Custom Gravatar in the WordPress Comments?
- Delete pages and Create default pages for all new network sites
- Actions according to image type and size
- How to use max and min values of custom fields
- Post thumbnail relative link and HTML modify
- Refactor create_function
- adding custom classes for tables
- Pass Shortcode Attribute to footer Script
- How to mass-delete inline styles in WordPress custom post type automatically?
- How would go about if I just want a temporary function?
- Remove the deleted users avatar from list
- How to call custom function from functions.php in site-wide template files?
- Customizer field value into functions.php variable
- PHP files included in functions.php don’t seem to work
- How Can I Expand the WordPress Customize window without any Plugin?
- Set quantity of woocommerce product on page visit [closed]
- wp_dropdown_categories and custom attribute
- str_replace function in theme
- Automatically wrap multiple images in div
- Ajax not working properly
- Retrieve tags data in post body
- Run function when WordPress new multisite is created or ACF field is updated
- Having issues with a foreach inside of a shortcode with ACF gallery
- Add caption functionality to custom WordPress theme
- is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
- Right way to update widget on dynamic new input field
- How to customly read JWPlayer’s “Playlist” items by using its “playlistid”?
- Include default functions and methods
- Hard-coding custom menu elements for menu manager
- Twentyten Child Theme: header images display messed up in admin panel
- How can I remove the main description text box in a Woocommerce product editor page? I only use the “Product short description” text box [closed]
- How can I modify all existing tags while keeping the urls themselves?
- Best practices regarding the creation of custom widgets?
- IF Statement on Button to make it complete and “uncomplete” based on user action / click
- Get Current Post ID in functions php, meta query filter
- Gravity Forms Button Text
- Find resources dynamically loading and change or add to the url
- When sale price is 0.00 show only regular price
- Unable to login using username
- Get Value of Custom Field
- restrict access to specific urls on a specific period of time
- child_of not working while searching
- How to request login for user but not for bots
- functions.php / replacing div’s with new ones?
- Why does modifying my functions.php file always result in a server error
- does acf_save_post cause endless loop?
- Post variables not displaying correctly in custom function
- Remove snippets of JS from core
- Show stuff everywhere except single post?
- Call ACF data from functions.php [closed]
- Removing Facebook contact field from user contact not working
- How do I add functionality to images?
- Explode Array from Repeatable Custom Field
- WordPress Custom wp mail template return full template
- Problem with removing characters “<” – WpAllImport
- How to create a post without link in wordpress?
- How to crop image in WordPress with aspect ratio for any size of image
- multible shortcodes (for differnt values) with one function
- Update post meta with wp cron
- post_row_actions filter from parent theme not executing in child theme
- Customizer cuistom CSS Priority ordre Issue
- Copy and Modified WooCommerce function is_coupon_valid [closed]
- BuddyPress Edit activity function good practice
- wp_login_form display no styled form
- Advanced Custom Fields in WP_Query: Clickable Text in List Format
- How Do I Prevent Featured Image Caption Displaying Above And Below Image
- warning: trying to access array offset on value of type bool ACF field image group
- How to capture number input from wordpress form into acf field in woocommerce
- Uploading images via ACF update_field function
- Add custom css to specific user
- How can I restrict comments on WordPress, so only the POST AUTHOR and the user who commented can see them?