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:
- When should you, and when should you not, use wp_list_pluck()?
- Display random categories on the front page (Finding and Editing Theme Functions)
- opening links in new tab using – add_filter( ‘the_content’, ‘make_clickable’);
- 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
- Functions.php: If its single?
- How to add a rel attribute to images that contains their categories?
- Preferred Use of home_url()?
- 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
- Post thumbnail relative link and HTML modify
- Refactor create_function
- 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?
- str_replace function in theme
- 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”?
- Twentyten Child Theme: header images display messed up in admin panel
- 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
- When sale price is 0.00 show only regular price
- Word Press – Dynamic Content [closed]
- Insert image in WordPress with HTML5 tag and caption function
- how can I just add to parent theme function(s) instead of redeclaring whole the function
- Move Custom Fields on General Settings Page to New Location
- Skeleton Child Theme Add Icon Bar to Header Flex Grid
- Redirect to another page using contact form 7? [closed]
- ACF not showing
- How to retrieve the values of a sub-field in the first and last row of an (ACF) repeater inside function?
- Condition OR for current user ID
- How to retrieve the current post’s generated featured image size?
- Custom Behavior when Adding New Custom Post Type in Dashboard
- Where do I store custom functions that call custom page template files?
- Why There Is No “get content by ID” Function
- Custom HTML markup
- Use a shortcode to display custom meta box contents
- Wp-query Order By problem
- Access category within rss2_head hook?
- Create custom function for hero image
- Can set_post_thumbnail be used to remove a thumbnail?
- Randomizing wp_tag_cloud() in child theme
- How to append classname to body tag if guest user
- Compare meta key to current date in pre get post
- Where do I go to edit this area? [closed]
- Replace plugin function with a custom function?
- Best way to disable sidebars on posts (only)?
- Problem with images URL after filter applying
- Function to replace comment’s accented characters before posting
- How to echo Widget Title in Custom Frontend-Template Box
- loginout function customization
- Perform function on publish AND save (not just save)
- implementing a centralized content “show-do-not-show” toggle?
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- How to display this meta data (an array) in form of a function (created with a custom write panel)?
- WordPress – using sessions?
- How to display an image before title text in menu items
- How to replace ACTION url from original wordpress login form?
- Save_post – Warning: Cannot modify header information
- How to use WP conditional tag in a functions.php with OCEANWP Theme?
- Modifying a WordPress Plugin
- CF7 select value get to function and reciept value from function
- External api call and make global variable for any page visitor enters , page-home, page, single etc
- CSS style and app.js not loading
- Parent category as WOOCommerce Categories widget title
- Extend WordPress Audio Widget to accept HLS (.m3u8) URLs
- ACF Date Form in Custom Admin Field
- Using AJAX on frontend: Synchronous XMLHttpRequest deprecation except for admin role
- Woocommerce custom calculation function
- Remove all video attachment, both files and post/postmeta from database?
- ACF Filter return value
- WordPress function with attribute pass to template
- Will dequeueing in child theme functions.php file prevent Google Fonts from loading?
- Replace image attributes for lazyload plugin on image elements with specific class
- How to make an If Else on Excerpt Filter
- Providing fallback function and allow override by plugin
- How to replace words in my posts and saved new words
- 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
- Post variables not displaying correctly in custom function
- Show stuff everywhere except single post?
- Call ACF data from functions.php [closed]
- How to crop image in WordPress with aspect ratio for any size of image
- multible shortcodes (for differnt values) with one function
- Customizer cuistom CSS Priority ordre Issue
- Copy and Modified WooCommerce function is_coupon_valid [closed]
- Advanced Custom Fields in WP_Query: Clickable Text in List Format
- How Do I Prevent Featured Image Caption Displaying Above And Below Image
- Uploading images via ACF update_field function
- Add custom css to specific user