You need a post_meta
field to let an author decide after how many paragraphs the ad is inserted, if you want to do it like that, and not with a shortcode.
So create a custom field called f711_insert_after_no_p
, and use your function like this:
if ( is_single() && ! is_admin() ) {
$show_after = get_field('show_after');
return prefix_insert_after_paragraph( $ad_code, get_post_meta( get_the_ID(), 'f711_insert_after_no_p', true ), $content );
}
Be sure to validate the input to only allow integers, or do this in the output.
I think for ACF the code (instead of get_post_meta( get_the_ID(), 'f711_insert_after_no_p', true )
) would be
get_the_field( 'f711_insert_after_no_p' )
Related Posts:
- Get posts by meta value
- post formats – how to switch meta boxes when changing format?
- Execute action after post is saved with all related post_meta records (data)
- advanced custom fields update_field for field type: Taxonomy
- update_post_meta not saving when value is zero
- Restrict post edit/delete based on user ID and custom field
- get_post_meta returning empty string when data shows in the database
- publish_post action hook doesn’t give post_meta_data
- Remove post meta keys
- How to get all term meta for a taxonomy – getting term_meta for taxonomy
- delete unused postmeta
- Should I sanitize custom post meta if it is going to be escaped later?
- Using Advanced Custom Field (ACF) to insert meta description on each page
- How to add meta tag to wordpress posts filter?
- Correct processing of `$_POST`, following WordPress Coding Standards
- Metabox Data not being saved [closed]
- Options to get my custom post type metadata via the WordPress API
- Generate an Email address from that of the Post Author
- How to get the total number of meta_values based on a custom post type?
- Does “update_post_meta” check if value is the same before updating?
- Add a meta value if admin , editor or any other user have open a post in edit mode
- How to show Published date and/or Modified date
- Finding the page id
- WP_POSTMETA – What do these values mean inside the data structure?
- Update Line Item Meta Data – WooCommerce API
- How to use update_post_meta inside wp_trash_post
- Display All Custom Post Fields and Values, Unless Empty
- Unset field from an array not working as expected
- Update post_meta with WooCommere variation data
- What type of index should I use for postmeta?
- Post MetaTable Overload
- Meta function issue
- Custom RSS Feeds & Post Meta Data
- Get a row from a separate table by matching a posts meta_key to a tables ID column
- get_post_meta is showing file url in url bar
- Save post meta foreach loop
- Should I save this mulit dementional arary as one post meta?
- How to check if a post meta key/value pair already exists for a specific post
- Reset/delete post views meta/custom field after X hours or minutes or seconds
- mass delete posts based on metadata
- Have lots of meta for posts, is it better to get at all at once or each individually
- Query posts WITHOUT a custom meta field
- Add box with custom per-page properties
- get_post_meta not working when variable used for post ID
- Update post meta dynamically
- Duplicate rows in meta table, any known relations in WC?
- Adding Custom MetaData
- Suggestion to make posts have multiple associated items
- Is it safe to add a new field to meta_value field?
- Need a SQL query to update meta_key=’_price’ with value in meta_key=’_regular_price’
- Display current user’s custom post meta in sidebar
- Why is my get_post_meta not properly calling the custom field when attempting to embed a YouTube video?
- add_post_meta doesn’t work
- If ACF meta_key has meta_value
- How to echo value of a meta select box to the browser
- How can I use ‘orderby’ => ‘meta_value_num’ to order by the numerical value even if the value starts with a word?
- New Table vs Post / Comment Meta
- Repeated nav bar queries failing to be cached
- Randomizing Post Links Outside of Loop – No Author or Date
- How do I add a fixed value to get_post_meta();?
- Add post’s category as a meta tag to the post
- Insert Custom Field Value
- How can I query for posts using a date stored in post-meta?
- SQL query – get a featured image’s alt / alternative text
- get specific values from WordPress meta_value
- Is duplicate `_wp_attachment_image_alt` meta key allowed?
- How do I list taxonomies that have upcoming events in WP? Is there a way to do this without having to query posts first?
- How can i set media attachments to the author of the post or page for already existed posts with attachments
- Strict comparisons problem when using boolean post meta
- Why is the actual number of thumbnail images not matching what is store in an attachments metadata?
- How to get posts by meta value as multi-dimensional array?
- Add post meta data date to event
- How to modify default meta link format
- Combine meta query and give a specific meta query a higher priority
- Something adding an excessive meta description
- Get table parameter and save in meta value
- How can i show post views using specified post ID?
- How to add/update post meta to use in query?
- Move Entry Meta Above Title in Archives (Genesis + Brunch Pro)
- how to query posts using value in meta post array
- Why doesn’t wp_oembed_get() for the video post format not work?
- Custom Meta Fields that are Echo’d are removed on post update?
- How to add dynamic content in title and meta description in wordpress theme for homepage, post page, category, tag and pages
- How to call get_post()?
- Exclude category from DB query
- add_post_meta only adding 1 character
- How to sort by meta value num, but ignore zero value?
- Posts with no meta field do not appear when sorting by meta field
- How do I delete element from a serialized array upon deletion of a post?
- Fetch post meta data on POST request
- Which query method to use? (edit- wpdb syntax problems)
- Get meta information from post parent
- How to update post meta with xml data
- Counting number of identical meta keys
- wp_postmeta store multiple values in one key [closed]
- How we insert values into database using metabox WordPress?
- query with custom field
- Using Form to alter PHP variable [closed]
- Chance post id into post name
- get_post_meta() returns nothing in save_post, publish_post, wp_after_insert_post