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:
- Display random categories on the front page (Finding and Editing Theme Functions)
- functions.php inject inline css
- opening links in new tab using – add_filter( ‘the_content’, ‘make_clickable’);
- Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
- How to customize search result page title?
- 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()?
- Custom function for user register in wp?
- Best way to programatically add “rel” attributes to page and post images
- 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 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
- str_replace function in theme
- 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
- 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”?
- Hard-coding custom menu elements for menu manager
- Twentyten Child Theme: header images display messed up in admin panel
- 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
- 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?
- How to retrieve the current post’s generated featured image size?
- Custom Behavior when Adding New Custom Post Type in Dashboard
- Why There Is No “get content by ID” Function
- Custom HTML markup
- Use a shortcode to display custom meta box contents
- 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
- Programmatically add Yoast meta description after post save
- Where do I go to edit this area? [closed]
- Replace plugin function with a custom function?
- Best way to disable sidebars on posts (only)?
- Using two loops in one WordPress template
- Function to replace comment’s accented characters before posting
- Linking Javascript in functions.php file
- Perform function on publish AND save (not just save)
- I would like single.php to act just like index.php
- How to show ACF value under post/page title in wp-admin
- How to display an image before title text in menu items
- Filter works on last selection but no others
- 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
- ACF Date Form in Custom Admin Field
- Using AJAX on frontend: Synchronous XMLHttpRequest deprecation except for admin role
- Assign IDs to headings in ACF using functions.php
- How would I correctly implement a new if statement in a child functions file?
- Woocommerce custom calculation function
- Remove all video attachment, both files and post/postmeta from database?
- ACF Filter return value
- True email confirmation for registration (keeping unvalidated users from user table)
- Replace image attributes for lazyload plugin on image elements with specific class
- How To Show Shortcodes In WordPress Custom Fields?
- Return ACF Field value function
- How to make an If Else on Excerpt Filter
- Providing fallback function and allow override by plugin
- Different body image backgrounds on different pages, posts and categories
- Get Value of Custom Field
- restrict access to specific urls on a specific period of time
- How to request login for user but not for bots
- functions.php / replacing div’s with new ones?
- Post variables not displaying correctly in custom function
- Show stuff everywhere except single post?
- Call ACF data from functions.php [closed]
- How do I add functionality to images?
- WordPress Custom wp mail template return full template
- Problem with removing characters “<” – WpAllImport
- How to create a post without link in wordpress?
- multible shortcodes (for differnt values) with one function
- post_row_actions filter from parent theme not executing in child theme