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!
- Strip and print only the numbers found in current’s post excerpt (even if they are without space)
- Automatically add custom CSS to new posts using a category template
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- Use object in template part
- How do I display a user’s previous orders as a select box option on a product?
- Using file_get_contents with Gravity Forms uploads folder to create images in the media library returning false
- allow subscribers to see private posts without plug in
- Replace word in “the_content” only for index.php
- How do you add customer capability after Woocommerce purchase?
- How to get specific image in media library with php
- Function set default image when image not present
- Render ninja form inside markup
- Custom location for attached images
- WooCommerce – Reset quantity input field when variation changes
- Query all posts of a custom taxonomy term
- get current product name in functions.php
- Setting custom canonical urls
- Handling Body class based on Template
- Trigger popup in a php if/else statement
- Setting a cookie upon specific URL visit
- Get_avatar filter?
- Can’t get page content in WordPress
- WordPress child theme fails to override parent navigation menu in /inc/structure/header.php
- How can I add multiple ‘tax_query’ arrays via a loop?
- Way to querry data (tags) from a wordpress database?
- ACF page while loop breaks footer while loop
- get post based on category chosen in drop down – The ajax method