Perhaps this is what you mean?
<?php
//Insert ads after second paragraph of single post content.
add_filter( 'the_content', 'prefix_insert_post_ads' );
function prefix_insert_post_ads( $content ) {
$ad_code="<div>".sewp_381661_get_advert().'</div>';
if ( is_single() && ! is_admin() ) {
return prefix_insert_after_paragraph( $ad_code, 2, $content );
}
return $content;
}
// function to return ad markup / logic ##
function sewp_381661_get_advert(){
$a1 = get_field('fa1', 'option');
$string = ''; // define return var ##
if ($a1) {
$string = '<a href="'.$a1['a1-l'].'" target="_blank" rel="nofollow"><img src="'.esc_url( $a1['a1-b']['url'] ).'"></a>';
}
// return string for echo ##
return $string;
}
Related Posts:
- How to set and use global variables? Or why not to use them at all
- How to Add Image to WordPress RSS-Feed with no Plug-in?
- Is it possible to disable a function of a parent theme?
- Hide old attachments from wp media library
- How to remove a metabox from menu editor page?
- Enqueue Javascript Correctly for 3.5
- How to add active class to custom menu using while loop and wp_list_pages
- Cleanest/Fastest way to avoid calling and retrieving data from the database multiple times?
- Add footer.php to WordPress child theme
- Need to get specific data from array
- WooCommerce – Display variation custom field value [closed]
- Restrict WordPress File Type Uploads by User Type
- New Plugin Review
- Problems with function on function.php
- Woocommerce HTML email option unavailable
- Use template for posts with a particular category grandparent
- How to slow down server response
- Click loads template via ajax
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- Function set default image when image not present
- jQuery not defined
- Use menu link or onClick to set a variable
- Automatically remove a canceled order in Woocommerce
- Trying to establish connection to External Database
- WordPress add post format support not working
- How to remove the cufon script from Dzonia Lite theme [closed]
- Login/logout in header
- How to put “Read more” link in Custom Excerpt inside p tag?
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Get users that likes the post
- Create highly customized submenu (possibly using wp_list_pages)
- $wpdb->wp_users returning empty value for
- WordPress Custom field Colors
- php syntax : [ && ] between commands [closed]
- My custom get_the_excerpt() can’t get excerpt by ID
- Which PHP page is the Default Posts Page
- meaning of (array)function()
- Need to put a script above tag in header.php – WP 5.7.1
- Sending a custom form data in email through WP Mail Function
- deactivating an active plugin using if page
- Isotope Drop Down Categories Filter Function
- How to use array in function to get only value I want
- List all blogs, but exclude the main site
- use loop to return blog details
- How can I count ACF sub_field with a certain value
- change the default order of posts only for specific categories
- Fetching Initials of the Commentator in the WordPress Website
- Adding function to child theme’s function.php
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Custom posts password protect
- How to get post category list as select in front-end?
- How to use functions [closed]
- Splitting the_content() by size?
- Extract and display user infromation on an automatically created page
- Is it legal to redefine wp_password_change_notification in a mu plugin?
- How can I assign separate stylesheets to different pages?
- Function to call either single post or category
- WP Container Displaying Only on First Page of Archive
- Updating Metadata with Shortcode
- can’t load .po file in functions.php
- WP-Bakery – Add custom colors to buttons with template colors
- Woocommerce – Exclude variation attribute on specific variation
- How do I add a function to parent theme
- Are there any drawbacks on opening a session_start in functions.php and header.php?
- Create shortcode for metabox gallery
- Add Pre-Defined Value to Click Counter in WordPress
- How can I redefine WordPress wp-content directory programmatically?
- Trim Titles Only On Some Pages
- How to move a post from one category to another
- Show data obtained from a function and place it in a shortocode function
- How to override theme’s public static function inside of a trait?
- Delete empty title_tags, find a h1 heading and echo it
- Enqueue sripts and styles only if function is called
- how to use 2 index.php file One for mobile and one for desktop
- WP_Query To Display Product Of Brand On Taxonomy Page
- ajaxurl usage for a custom function
- oembed facebook link?
- Open/closed function [closed]
- How can I export data without using any import/export plugin
- Search for images that width and height is more than 500
- add a value to an external link query in searchform
- Add disclaimer before certain posts and pages
- How do I routinely extract the thumbnail of the most recent post?
- wordpress ajax return 0
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- site_url() returns with additional backslashes
- Overwriting a Shortcode
- How to get category pages to look like a certain archive page?
- Search box background on a different page template
- WP Ecommerce: Display the “Order Notes” as column in the Sales Log [closed]
- How to call a specific value within the functions.php file?
- A next page function with shortcode?
- What is the wrong with this function to enqueue the scripts and styles to the theme? [closed]
- Warning: Attempt to read property “term_id” on int – Woocommerce
- Warning: filemtime(): stat failed for wp_
- Keep users logged in Without Remember Me
- How to use js variable to php in wordpress functions.php
- Automatically change insurance quantity based on cart total [closed]
- How to pass value to add_filter wpcf7_form_tag from another function?
- hiddenQuestions.find is not a function