Use strtok()
:
return strtok( get_the_title(), ',' );
You could also use my function utf8_truncate()
. This is a little bit more flexible and it can handle long strings without a comma.
Related Posts:
- Error Warning: Declaration of description_walker::start_el after PHP upgrade [duplicate]
- Displaying Logged-In User Name in WordPress Menu
- Autoloading in Child Theme
- Set media upload attachment link to none and hide it in WP v3.5
- Fatal error: Call to undefined function plugin_dir_path()
- Switching wp_get_sites to get_sites
- One button to change all settings in theme customizer?
- Add custom image sizes to media uploader
- Add/echo div with Analytics-Code to function in functions.php
- How do I list the_tags() into HTML data-attribute
- WordPress if (is_page) translation on certain page
- Check if term object is in array
- Highlight Current Tag in wp_tag_cloud
- Getting rid of role=”navigation” in the Home Page Pagination
- How to use return in my custom function instead of echo
- Setting custom canonical urls
- Trigger popup in a php if/else statement
- Setting a cookie upon specific URL visit
- get post based on category chosen in drop down – The ajax method
- how to make separate field in wordpress user_data_
- Add a class to the anchor tag on HTML5 gallery
- Conditional Header in wordpress
- How to output a PHP file values by shortcode?
- Set the background to a default image if there isn’t a specified “featured image”
- Calling directories to load in wordpress
- WordPress Access allowed to fewer pages till user logs in
- Use DOMDocument with ob_start breaks my HTML code
- Display a specific category of products in shop page and disable code for specific actions
- different id for same element visual composer [closed]
- Tax query in pre_get_posts not working
- trigger html cleanup for all posts
- Validation algorithm in checkout field
- Catchable fatal error: Object of class stdClass could not be converted to string after WP 4.7
- Need help enqueueing webfonts
- Add class to group inner container
- Use .php file as page instead of wordpress page & template file?
- Illegal string offset in PHP function
- Find hours between post_date and post_date_gmt
- How to remove ?p= from wordpress short links
- Displaying text if post was within 5 hours
- Convert the_permalink() function output into string
- Adding a tag_ID column into Categories inside the admin dashboard?
- Need php code’s output to display underneath a Divi Module
- WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
- How to make function appear in sentence?
- How to define a variable already defined in a plugin function?
- woocommerce specific quantities for product
- My website is not showing Footer section
- get_current_site() is undefined
- Custom query vars filters problem with pagination
- Automatically Add Page Links to Nav Menu
- blank white page when post/update/change option etc
- Use SCSSPHP to compile Theme Customizer Values into .SCSS files ready to compile to CSS
- Must filter functions receive all arguments passed to them?
- How to Display a List of Child Pages For a Parent Page in WordPress
- writing an unique php function to be used on my website
- Displaying Slider in Front Page (home) using Customizr Theme
- How to add PHP pagination to wordpress
- Taxonomy term description with style, only if the description exists?
- Restrict post to current user in postmeta
- How to change the author box selection on a post to a custom taxonomy
- Output product category link from WP_Query
- Adding onload to body for certain pages
- How to send a php var to jQuery Ajax call with two different file
- Change wordpress’ database data using ajax – how to get current user id?
- copy fields value to another field
- not outputting medium size image URL
- posts_per_page displays only 2 posts instead of 4 posts
- Get parent category name when only child category is applied to a product
- Best way to use variables in multiple functions?
- Can an AJAX callback function access a PHP variable which was defined during initial page load?
- Adding product permalink on admin order page throwing error
- Before & After Content – After Content directly below Before Content when using require_once
- Cannot fetch posts with certain ‘product_cat’. WP_Query is empty
- Detect what link user clicks and Redirect to a specific page for logged in users only
- Offset with ajax load more posts duplicates
- How to call WordPress PHP file using external js file
- How fix error in the WordPress loop?
- use system script advertising in wordpress multisite
- Use WP_Query Data In Cookie
- Extend the WP_Customize_Image_Control class to change its non-frame $button_labels
- Insert wordpress tags below posts via functions.php
- Help with my first Metabox helper class
- syntax error unexpected ‘}’ at 364 line
- get_post_meta no longer working
- ISOTOPE – Missing/Invalid Arguement Get Terms
- Showing all post from all post type in admin backstage
- Pagination not displaying
- Trouble figuring out how to get my button to submit comment
- Setting WooCommerce currency programmatically
- Masking external links with internal link for member-only
- Shortcode to include PHP file, pass various parameters to include?
- Why can’t I include echo inside a variable? [closed]
- Assign new post author IF another user in custom field on post transition
- Create and publish a new post every Monday, listing the post titles and links to the posts published during the previous week
- Dynamic Email Handler with ‘header (“Location: …’
- WooCommerce: write featured image dimensions to custom fields in product’
- Generate and upload screenshot as featured image for user-submitted post
- transition_post_status hook, works – but not if the post is new
- Custom plugin doesn’t show in admin menu – when code added, displays an empty page