the_title_rss()
outputs its value straight away so it can’t be used in a function like that, you would have to use get_the_title_rss()
Or alternatively the_title_rss() has a filter we can hook in to and return your shortened title is possible. (You would add this to your functions.php)
function gg_short_title_rss($title)
{
// This can return false, so check there is something
$short_title = substr($title, 0, strpos($title, ' –'));
if ($short_title) {
return $short_title;
}
// Else just return the normal title
return $title;
}
add_filter('the_title_rss', 'gg_short_title_rss', 10, 1);
Related Posts:
- Custom field in title
- How to update custom fields using the wp_insert_post() function?
- Most efficient way to add javascript file to specific post and/or pages?
- Where does php code to load data go?
- ACF – Can’t get custom post type by taxonomy
- What is the correct way to search 3 custom fields only in WordPress?
- wp_get_nav_menu_items() with ACF
- Save custom field on WP_List_Table
- How can I get the custom post title?
- Sum All the Post Meta of Published posts of Current Logged in user
- How do I get the value of a current user’s custom field?
- Trying to retrieve meta values from three different meta keys and display in rows
- Site title not showing. Please help me
- WP post meta – for loop inside for loop
- How to display custom seo title before the loop?
- custom fields anchor points php
- Store custom field’s multiple values in one user meta key
- Get field in readable word
- WooCommerce multiple custom fields code
- When working with a post, almost all wp_postmeta are deleted
- Put a span class in the shortened product title
- Allowing HTML elements in title widgets spacing problem
- What syntax is this? “{{post.price}}”
- Updating Lat and Lng of posts automatically gives sporadic results
- How to display custom field from a gallery thumbnail?
- WP_query meta_query slow with OR and DATES
- Get meta_query value by user meta array
- How to use something like meta_query but for fields?
- Getting a value from a custom field from a page that shares a parent with the current page
- meta field for numerous links
- “Page Array” displaying in title bar on Front Page
- Custom fields changes the formatting of metabox input
- Replace Underscore (_) on Space ( )
- Include a custom field in mysql query
- Display Content Based on Custom Field Value
- my site show this symbol (::) between site title and tagline
- php if, else & custom fields – syntax error
- How to get the first letter from custom field?
- Meta box not saving spaces
- Display tab title as ‘blog tagline | blog title’
- divide custom field values in div every two values
- custom field meta-box with dropdown/autocomplete
- Showing custom field contents without listing description
- How to exclude post from being queried based on custom meta value
- If custom field doesn’t exist, or exists and it’s true show title?
- How to link a word comprised of a custom field with another?
- If Elseif Query
- How can I put a custom field as the link of a button shortcode?
- Outputting a custom field in PHP
- Sorting Meta Fields?
- Custom fields randomly stop working
- Display selected parts from selected pages on the frontpage?
- Where can I find the code for the menu page meta boxes?
- How to echo a different field if another field is empty?
- How to use custom fields to replace top-level parent title with an image using wp_list_pages?
- PHP Puzzle: Unique Styles with PHP loop
- I want Page titles and excerpts to show up on home.php in certain order
- Posts sortable column not sorting properly for custom field numbers
- Hide page title
- Search result page – display values from the result’s metaboxes
- Display custom meta box in my template file
- Query posts by custom fields (object post)
- ACF Date fileds to Age Convert [closed]
- Save custom field value to variable for conditional – why is this not working? [closed]
- Metadata on the WP_Post object
- Appending an ACF custom field to the page title
- Too many if’s and else if’s ?? – Must be better way [closed]
- Advanced Custom Fields Show PHP in Text Areas
- WP query with variables gives no result for specific user
- Grabbing value of input field inside of array
- Getting a specific “title for a section” only on Startpage?
- Displaying custom meta box value in a custom post page
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- Convert custom field date format to “WordPress default”
- I want to show image from custom field image on my custom page template
- How can I change the location where the custom field is displayed in the Quick Edit tab in WordPress
- How do I organize posts based on their taxonomy?
- How do you create a front end form that enables the editing of member-specific custom fields in WordPress?
- Search custom post type posts only by meta fields?
- How to pass value to add_filter wpcf7_form_tag from another function?
- Custom Admin Menu Report for Specific User ID
- Shortcode Displays 2 times
- How to execute a shortcode within a custom field?
- ACF number less than comparison not working
- fetch from an external api call and display results in page
- Problem with custom user fields default value and retrieval
- Cannot Access ACF Field Values via my Plugin
- wordpress-plugin (widget) that performs a Neaby-search on the openstreetmap-endpoint: around x find y
- How to create advanced custom fields for backend content
- ACF block gutenberg aligncenter don’t work
- How to pull through page title depending on which radio button is selected on the specific page?
- Display WooCommerce Order Custom Field In Template (HPOS)
- How can I display a layout differently depending on whether the user is on Mobile or PC?
- hide “Open in New Tab” checkbox in link field
- Want to add custom post type for facebook feed
- Exclude function for custom pages, exclude custom ACF fields
- Split titles by the ” – ” in WordPress
- Is it possible to remove the “Shop” title from the WooCommerce catalogue? [closed]
- Custom rest fields not loaded in rest api cpt response
- Display posts in correct month order using single date custom field