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
- Adding an option to a shortcode
- How to use author meta in shortcode?
- Using multiple line variable inside a function?
- Testing for a shortcode using a function. 404 page throwing PHP Notice
- Use a shortcode to display custom meta box contents
- 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
- issue with if/elseif in_array inside foreach loop display only one post
- does wp function the_content(); accept another tag inside
- How to parse a shortcode within a shortcode?
- Variables not showing in short code
- Undefined variable error in new function
- How to remove a specific word at the beginning of the content and add it to the end of the content
- Woocommerce checkout field
- How to include any template using Shortcode fuction?
- How can I pass a shortcode value to the head in wordpress functions.php
- Native gallery custom html output
- Genesis Framework: How to exclude a specific author from archive custom loop
- Problem with calling custom function in a foreach loop
- Need to convert image url to a Base_64 data url with wordpress function..
- The_content and Preg_replace in loaded Iframe [closed]
- dynamic site link for future migration in echo do_shortcode()
- How to create shortcode with html and php content?
- first paragraph of the_content as meta description
- Tracking the number of shortcodes for a list?
- Need a method to prevent WP from adding in between my shortcodes
- Load scripts for do_shortcode( ‘ [ my_shortcode ] ‘ )
- Get term slug by term id and then explode it
- posts within custom post type all share the same content in the front-end
- Shortcode question
- Using functions.php to include code that’s processed inline
- Can I include a custom PHP function in a WordPress function?
- Changing where my author box is printed
- How to create a shortcode out of a php function
- Insert Content Before div#main from the functions.php File
- 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
- If is_single in functions.php
- Strip from or something better?
- Shortcode of a function
- Conditional function for excluding first image from content, not working
- show all the posts thumbnails
- How to add a shortcode to call a function
- How can I call a PHP function inside a hardcoded shortcode?
- Simplest Way to Build Custom Archives Page?
- Problem with shortcode inside a shortcode
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Get Posts List of Current Selected Custom Taxonomy in Shortcode
- Need help making a short code work
- Using One Function To Create Two Different Shortcodes
- Is it possible to create a shortcode to link to a specific post/page where the tag is just an attribute?
- Display a list of random terms from custom taxonomy with shortcode
- the_date() and the_time() functions display actual date an time instead of published date and time
- Load templates, pass arguments, and render output from functions.php
- How to add if statement on WordPress shortcode output
- Passing function arguments via a shortcode
- Pagination not working – FrontPage
- Customizing the wp_video_shortcode output with add_filter
- page shows short code not output
- Probleme shortcode with list author
- Function to function shortcode help [closed]
- Last updated posts shortcode in functions.php
- I want to display the sku in the product pages of my EDD website
- 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
- Shortcode to insert default text and change one word throughout it?
- Pass post ID from archive template to functions file
- Strip all HTML tags from product content and resave
- Prevent function from triggering on current page
- use add_action in a shortcode (gravity form – WordPress)
- How to use `foreach()` in ajax call
- Shortcode displaying outside the div [duplicate]
- Shortcode Initialization in a Custom Theme
- Shortcode with pagination advancing multiple queries
- Remove External Links from WordPress posts Using add_filter() in Theme functions.php
- Show users last read posts for each user?
- Get shortcode attribute value to another function
- How to retrieve image IDs from shortcode content?
- Split Content and Gallery
- Display list of pages that contain a certain string within the slug
- $content is empty while using DOMDocument
- Hide disclaimer from summary excerpts
- HowTo: Add wrapper to columns shortcode?
- Code executes outside of Loop while same code gives ‘Uninitialized string offset’ notice inside a while loop
- Function not receiving string from shortcode
- How To Show Shortcodes In WordPress Custom Fields?
- Shortcode Function – Can’t get anything else to return after running shortcode within shortcode
- Only seems to be displaying one child when there are supposed to be multiple
- Custom shortcode with do_shortcode and substr