I’d simply set a flag as second input argument for the function:
function new_wp_trim_excerpt( $text, $case="plain" )
{
switch ( $case )
{
default :
case 'plain' :
// do stuff - your function so far
break;
case 'image' :
break;
}
}
Notes:
- Avoid names like
class="moarplz"
. It’s hard to read for others and hard for yourself in a year. - Never
count
inside anif/for/while/foreach/else/elseif
statement – it’s up to 5 times slower than counting it in the line before.
Related Posts:
- Loop on a wordpress Page instead of content coming from the WP text editor
- What is This esc_html_e() i wordpress php?
- Check if a menu is empty?
- Build a content and excerpt grid loop with paging and options for # of posts
- Displaying post per day
- How to loop over custom fields in a page template?
- How to add active class to custom menu using while loop and wp_list_pages
- Custom post type loops with different page templates
- delete an array element when its date expires
- How can I loop into two different DIVS without repeating the DIVs
- Easiest way to show total number of subpages
- Use template for posts with a particular category grandparent
- Word Count Function Preventing Permalink Editing
- Add a Second Menu to a theme that only support 1 menu
- How to speed up a wordpress function with multiple loops?
- How to Display a Single Post Excerpt
- How to remove the excerpt in the Dzonia Lite theme
- Get first URL from post content
- Mass update excerpt
- Show css depending on activity type in BuddyPress activity-loop [closed]
- How to put “Read more” link in Custom Excerpt inside p tag?
- Error when adding excerpt to the content through functions.php
- get author_name from queried post
- Blog posts repeat
- how to refresh div on template part?
- Can’t find infinite loop cause
- Checking array against author id in loop
- Query Pages and post excerpts dynamically
- My custom get_the_excerpt() can’t get excerpt by ID
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- Use WordPress function in php file
- Adding wrapper elements in the_date() like in the_title()?
- Custom Pagination is Broken
- How to call multiple functions from multiple files into a WordPress page template [closed]
- Function Reference Documenting Template Tags for use in Custom Theme Templates?
- Create page template via functions.php?
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- use loop to return blog details
- add_filter function concatenate string and locate_template function
- How to get current post category details inside “loop”?
- Template Loop – add switch case php
- Calling function in loop causes repeat data
- How to remove the space before the ellipsis in excerpt?
- Splitting the_content() by size?
- Strip from or something better?
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- Problem in replacing the_content with the_excerpt()
- How to Add a cutsom slug to my custom author role
- Products listing check if meta checkbox is checked
- Display articles with a different template in the home page | Solved |
- Display metabox galleries on specific page template in admin editor
- How to output the taxonomies that are assigned to each custom post?
- Check if current post in loop is last on current page
- update_user_meta as multiple value but with same meta key
- cURL needing to loop through all “next_page”
- WordPress Ajax filter: Create two loops for different output styles?
- How can I get my pagination loop to display the correct number of total pages?
- How to include a function in a template with template tag
- How to sort (orderby) a query done by a template function before the ‘foreach’ loop?
- How fix error in the WordPress loop?
- How to trim content AND retain HTML?
- My query keeps looping infinitely ! how to stop it?
- Retrieving specific images from Media Library
- Add point on excerpt post
- Loop returns more items than exist?
- Modify category archive page loop on functions.php
- Problems With Query and/or Template Part and/or PHP
- Pagenav Not appearing on custom Template
- why is this content-template not showing any of my blog-entries?
- Merging two excerpt functions to work with conditions
- php “use” not working in template [closed]
- Excerpt all post content Content Same Size without word cutting off
- Options.php loop won’t show!
- How to set and use global variables? Or why not to use them at all
- Displaying a WooCommerce product via PHP
- Enqueue Javascript Correctly for 3.5
- Add footer.php to WordPress child theme
- Restrict WordPress File Type Uploads by User Type
- How to slow down server response
- Click loads template via ajax
- How to remove or change the “W” icon in “My Sites”?
- getting logged in user info (wp-load.php) from parent directory
- Add content after the first post in WP Loop
- Where is this function’s callback getting its arguments from?
- How to get post category list as select in front-end?
- How to use functions [closed]
- Function to call either single post or category
- Updating Metadata with Shortcode
- How do I add a function to parent theme
- Are there any drawbacks on opening a session_start in functions.php and header.php?
- Add Pre-Defined Value to Click Counter in WordPress
- Change the “Show All” button in a WordPress Portfolio Filter
- Cannot figure out how to add a read more link to a manual excerpt. Please help
- ACF background-color per post in a WordPress loop
- ajaxurl usage for a custom function
- oembed facebook link?
- Open/closed function [closed]
- site_url() returns with additional backslashes
- Warning: Attempt to read property “term_id” on int – Woocommerce
- /page/2/ redirect to 404