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 get next day date of a specific day
- wordpress plugin is not activating from widget
- Theme my Login plugin, how to update fields
- Plugin Handle URL With Custom Theme
- Allow users of my plugin to define their own shortcode rather than use mine?
- Edit Yoast SEO breadcrumbs output [closed]
- Date calculations from 2 custom fields
- How to put JQuery/Ajax inside shortcode?
- wordpress prevent multiple shortcodes
- Can someone please tell me what is wrong with my plugin?
- Does WordPress validate inputs to all functions? (such as get_user_meta and insert_user_meta)
- Custom random quote widget breaks when used in multiple sidebars
- Trouble with editing template for “List category posts” plugin
- Using a function to change favorites listing
- WordPress Shortcode to get URL Parameters $_GET[‘name’] redirects for no reason at all
- Display post lists in 2nd paragraph
- WordPress function not being called from jQuery method
- How to debug error message: Cannot modify header information
- Using a post-signup hook to get user details
- How to enable specific plugin only based around shop manager role?
- How to change constants in WordPress wp-config.php programmatically?
- AddToAny shortcode in the loop
- Restrict media upload size by format
- How to use a class from another plugin
- Override Plugin Script Fucnction in WordPress
- How to display custom sidebar in wordpress 5.5.2
- How to add an automatic refresh in WordPress for a Page/Post or an embedded OneDrive/Excel HTML Code?
- Calling plugin function inside custom plugin for onclick event
- How to fix wrong attribute error for Visual Composer Grid Builder?
- Show function to super admin
- Making a Template for a CPT created by a plugin
- get current date + 90 days and checking every day
- Adding a new field to the address field type in gravity forms
- add_shortcode is not working in plugin where others are working
- 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
- How to create an input field, and base the output on spreadsheet data? [closed]
- Facebook Messager Plugin
- Shortcode Plugin to dynamically build a shortcode via `do_shortcode` not working
- Making sure that a plugin’s scripts and stylesheets are included for dynamicaly loaded content
- Fatal error: Call to undefined function cmsms_theme_page_layout_scheme()
- Best place for short bio,image and button [closed]
- How to call WordPress function other files
- Insert content of a post into another
- All sites themes functions.php have been changed
- Customize permalink wordpress category id
- Conditional attributes and logic per product category
- Disqus deleted comments are syncing with wordpress but active comments do not
- Admin style for just one plugin in dashboard
- accessing wp.media api from a tinymce plugin
- Creating shortcodes in plugin
- Visual Composer shortcode for child theme dir
- get_post_title is not working on homepage
- Some code in shortcode function being ignored
- WP Query. Is there a maximum size?
- How to remove custom post type and add category and post name
- How to create a custom shortcode based on the layout?
- Grab WordPress Salt Data From URL
- Ajax : Call undefined function plugin_function() … can’t call any plugin function
- Unable to add TAB character to post?
- WordPress get_avatar function not correct working
- plugin shortcode output
- WordPress metaboxes – textfield suggestion automatically populated
- Is there a PressThis that doesn’t hotlink?
- bbPress plugin: forum lists not showing in correct order? [closed]
- Which file of wordpress manage plugins functionalities?
- How to Create a shortcode to this php function
- Inject HTML meta tag inside wordpress tag using add_shortcode
- How do I apply style to each category of a list?
- How to create an option page for this simple plugin
- Difference and examples of esc_attr__() and esc_attr_e()
- How to set Noindex to all wordpress pages in a catergory?