I’m pretty sure that is_singular()
is going to return false when you are inside the WP loop, since there are more than one posts being looped through. Try is_single()
or just look at the post object and examine the post_type
attribute.
add_filter( 'the_content', '_some_func', 15 );
function _some_func( $content ) {
if( __check_paragraph_count_blog( $content ) > 15 )
$ad_code = "the ad code";
else
$ad_code="";
return prefix_insert_after_paragraph( $ad_code, 12, $content );
}
function __check_paragraph_count_blog( $content ) {
global $post;
if ( $post->post_type == 'post' ) {
$count = substr_count( $content, '</p>' );
return $count;
} else {
return 0;
}
}
Related Posts:
- Autogenerate wordpress shortcodes using array?
- Shortcode display outside the div
- Shortcode under a Shortcode Multiple times Possible?
- May i Use ShortCode in Template?
- Prevent shortcode from being wrapped in tags
- Adding Shortcode to Text Widget
- Snippets: is it better to add them in functions.php or make site-specific plugins?
- creating html reusable blocks via shortcodes
- Nested shortcode functions accessing variable
- Calling an attribute from a plugin shortcode
- Redirect to another page using contact form 7? [closed]
- What is @Action in WordPress?
- Return multiple values in a shortcode attribute
- Shortcode Attributes to Return different $_POST
- strange shortcode error: does shortcodes requires any dependency?
- Add the_post_thumbnail_url to a shortcode in function.php
- Adding a Tag Parameter / Filter to My Shortcode
- grab or load text on demand
- Elementor Pro display featured image on section -> style -> image using shortcode
- How to get current cart values using WC_Shortcodes?
- Get Shortcode output to database for static post_content
- Find all strings between an enclosing shortcode
- wordpress Shortocode running twice?
- Posting code inside the post instead of in the template file using shortcode
- How to Set Limit with WordPress Get Bookmarks Shortcode
- Integrate Razorpay quick payments plugin with contact form7 plugin
- Shortcode cannot parse attributes within double quotes. ” is becoming ” breaking my shortcode
- How to override a theme function (within a class) using a plugin
- How to assign user a role if none is present when logging in
- shortcode doesn’t work
- How to remove action from plugin?
- How to find out what blocks are added by a plugin
- How extend shortcode default values for a plugin?
- Shortcode in AJAX popup
- How to Replace Words with Hypertext Link But Ignore Previously Existed Links?
- Can I use a Shortcode output as an HTML attribute value?
- Can wp_localize_script be used within a shortcode?
- Custom CSS for plugin form
- AJAX button run function
- Shortcode based chart plugin
- Input with spaces in Shortcode attributes overwritten by defaults
- Display post lists in 2nd paragraph
- How to display custom sidebar in wordpress 5.5.2
- Single API call exposed via shortcode with params
- Replacing a plugin function with a custom renamed function doesn’t work
- SEO Friendly URL on dynamic product page produced via shortcode
- Insert content of a post into another
- Disqus deleted comments are syncing with wordpress but active comments do not
- WordPress get_avatar function not correct working
- WordPress metaboxes – textfield suggestion automatically populated
- Which file of wordpress manage plugins functionalities?
- How to Create a shortcode to this php function
- Improving the perfomance of a plugin action
- Check if variable is set in filter
- Image change on hover
- Passing stored variables to add_filter
- plugin shortcode not working on ajax request call
- How to activate a plugin on the activation of a theme?
- JQuery prepend a function
- How to make a dynamic css class whose name changes every visit to confuse scraper
- Shortcode not working – quotes seems strange
- Using custom fields for image alt and title
- Where Should i write the code for wordpress ajax voting?
- How do I convert my WordPress website to be domain agnostic?
- Get Image Having the ID [closed]
- Add action to custom Function
- Show media-uploads to all users
- Echo out element to another page.
- how can authors to define custom pages?
- How do I create pages within a WordPress post?
- How to upload large media file in chunks, without any plugin?
- WP Function does not trigger on Webhook API Call
- Why do I need to reload the page for WordPress to see the new custom field added with jQuery
- Cookie value changes back to previous value after changing
- RSS Feed on WordPress showing code (hypertext) in articles titles
- Alternative Hook to the_content for Changing Background Color
- How to add specific script to WordPress webpage that will working with user input and databases
- Hide Plugin Custom Post Type Menu Link
- How to create algorithm for ordering posts in WordPress?
- Make the product page as homepage WooCommerce
- Shortcode function not showing up on mobile browser
- Add external javascript to post template
- Get Current Post ID in WP Loop For GiveWP
- Plugin function in child theme
- Shortcode generated widget to appear on same line as heading text and button
- How to make cover image in post block expand to entire screen?
- Update (a function) post’s featured image as soon as $image_url changes
- Why isn’t my plugin seeing other classes?
- Space in WordPress Attribute Causing Problems
- Shortcode registered from a plugin not recognized
- functions.php conditional output for a single plugin
- Single dash converted to double dash
- How use Dynamic hyperlink on each wordpress post?
- Embedding BitBucket Code in Posting
- Do shortcodes affect page indexing by search engines?
- Can’t modify plugin function
- PHP if url extension action=discussion condition use [closed]
- Shortcode to do math with url variables
- Buffered output in chunks and shortcode – how do I achieve that?
- wp_enqueue_script doesn’t load JS in plugin