Add a static variable to the shortcode handler to check if the shortcode has been called already.
Sample code
add_shortcode( 'wpse62826', 'wpse_62826_shortcode' );
function wpse_62826_shortcode()
{
static $done = FALSE;
// Nothing to do.
if ( $done )
{
return;
}
if ( is_singular() )
{
$done = TRUE;
}
return '<b>I run once on singular views!</b>';
}
Result
Related Posts:
- Creating mixture of shortcodes to use in the visual/text editor
- Automatically insert php function into post $the_content
- Custom Shortcode, functions PHP WP_Query loop
- How do I pull excerpts from pages?
- Output loop to function return?
- Shortcode to eliminate and replace with
- How do grab the main loop, with conditions, and output via shortcodes
- Split Content and Gallery
- Show modified time if post is actually modified
- How to display random users with avatars
- AJAX handler throws 400 (Bad request) – why?
- How to display the_post_thumbnail if a post has one or otherwise display the first image in a post?
- Creating a table from shortcode avoiding wpautop for each row
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- Stripping shortcode from custom excerpt function
- Formatting post content to exclude gallery
- Shortcode with custom content attribute?
- Shortcode to insert menu in page body?
- Passing HTML in WordPress Shortcode arguments
- A snippet after every image
- Creating loop within functions.php
- How to use max and min values of custom fields
- creating shortcode to pull json array
- Filtering posts by category name based on page’s slug
- How would I create a shortcode to display a custom post within a page or regular post?
- Pass Shortcode Attribute to footer Script
- Searching for content post
- 2 Loops, Only Displaying 1 Loop in Both Loops
- Display gallery on top before content
- List child pages of specific page using shortcode
- How to extract the variables out from “add_shortcode” function?
- create shortcode to list users with specific meta key value
- Variable if post is sticky in functions.php
- Showing content from one page on another
- Having a Function Inside of the Loop
- Display post shortcode content in the sidebar?
- Getting different functions data while using while loop in wordpress
- Create a new query in function.php to filter blog posts
- Using shortcode content with nested shortcode
- Limit length of first excerpt in the loop
- Custom shortcodes not inserting into visual composer columns
- Setting youtube size in functions.php
- Adding a colorbutton in tinymce dialog with current api
- Excerpts are not displayed by a shortcode on category pages
- Why doesn’t is_page(id) work in functions.php?
- check if the user is owner of current page
- shortcode help require
- Optimizing a WordPress site
- Use html inside shortcode function
- Insert template-part inside the content
- wp_nonce_field is breaking form for reasons unknown
- Remove links from the_content when using filters wp_trim_excerpt
- Visual Composer creating own shortcodes with vc_map() to return simple Image
- While loop with an exception after a count is reached
- Function shortcode – Set Parameter
- Using multiple line variable inside a function?
- Echoing function into WordPress NextGen gallery
- How to echo the value of an array element using a function via a shortcode
- Wp-query Order By problem
- does wp function the_content(); accept another tag inside
- Variables not showing in short code
- How to include any template using Shortcode fuction?
- Need to convert image url to a Base_64 data url with wordpress function..
- How to create shortcode with html and php content?
- first paragraph of the_content as meta description
- Get term slug by term id and then explode it
- Shortcode question
- Shortcode to get featured image of specific id post
- Modify shortcode to work with custom post types
- shorthand syntax for custom fields
- Breaking up multiple words and inserting an image after first word
- show all the posts thumbnails
- Problem with shortcode inside a shortcode
- Need help making a short code work
- Display a list of random terms from custom taxonomy with shortcode
- Load templates, pass arguments, and render output from functions.php
- Probleme shortcode with list author
- Last updated posts shortcode in functions.php
- How set a while with a function
- Shortcode to output category description by passing ID
- Help using ShortCodes to style whole chunks of the post
- How to use `foreach()` in ajax call
- HowTo: Add wrapper to columns shortcode?
- Shortcode Function – Can’t get anything else to return after running shortcode within shortcode
- Custom shortcode with do_shortcode and substr
- Can I use a function to return HTML and the result of another function?
- Function the_content
- Expanding a function to call a plugin or show a link
- Function to get the name in database table from the comma separated string
- Trying to the deduce shortcode from a function
- Pull random comment from specific post, display on homepage with shortcode
- How accomplish modification the_content if home/start page?
- Run function from parent on child site
- Way of getting queried loop before the query with a filter hook?
- Post variables not displaying correctly in custom function
- Shortcode Variations?
- Custom shortcode not being included in content paragraph [duplicate]
- how to handle multiple forloop?
- PHP error in shortcode [closed]
- multible shortcodes (for differnt values) with one function