While writing the question in SE I already found the solution:
add_filter( 'get_the_excerpt', 'get_custom_the_excerpt' );
function get_custom_the_excerpt($excerpt) {
$post = get_post();
$format = get_post_format( $post );
// modify excerpt if it is a quote, for example set title as author
if ($format == 'quote') {
$output="<q>". $excerpt. '</q>
<p class="quoted">'.get_the_title().'</p>';
}
// return excerpt without change
else {
$output = $excerpt;
}
return $output;
}
For details check get_the_excerpt() and get_post_format().
Related Posts:
- Is it possible to rename a post format?
- Is it possible to remove the “standard” post format?
- Difficulty with PHP function that displays a post’s format in WordPress
- How to add a data attribute to a WordPress menu item
- Order posts (across the whole site) by metadata date
- Functions.php code that only runs on localhost?
- hook a functions to change wp-config from functions.php
- Relative URLs and hide /wp-content/themes/
- Check if the user has explicitly set an excerpt
- Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php?
- Slugs as breadcrumbs for Pages
- Removing Unnecessary Text from Admin Menu without CSS
- Shortcode with custom content attribute?
- Add a Post Thumbnail to an RSS Feed with custom size
- Display WordPress Search
- Automatically add author’s name to post_tag
- Print Dashboard menu name and link
- Remove_filter (‘the_content’, ‘wpautop’) is not working
- Develop function get_template_part in functions.php
- Where does function_exists() look to decide whether a function exists? [closed]
- Change comment_reply_link URL
- Ajaxing function in widget class
- Clean-up script tags
- Make “sidebar template” the default template for new pages
- Refactor create_function
- WordPress function for 1 to for many
- Logic to Print/echo a css class only for 1st post and ignore all post after 1st? [closed]
- How can you limit srcset on a single type of page?
- Remove Font-Awesome MaxCDN Link & Load Locally
- How to fix Warning: call_user_func_array()?
- How to get specified parent page title in my function
- Execute function after a post has been published
- Select pages by category
- wp_register_script(… $in_footer = true) not working
- I want to get product attirbute in the section below
- Restore Image Title Text
- Output and filter data from a XML url
- How do I create a function that simulate the click on Update button for all posts?
- Multisite Ajax serialize return error [object Object]
- Full page template function
- Redirect from “private” page and functions.php which tag add to add_action()?
- Display gallery on bottom after content
- watermarking gallery items
- Wp admin – Set default value to 999 in comments
- WordPress listen to $_POST in functions.php
- WordPress Shortcode function display outside of widget
- Get rid of the widget Item Class=”widget-item”
- wordpress use single ajax in place of multiple ajax requests in a smarter way
- Add Element as a Filter to the_content
- Storing password (functions.php)
- Can’t properly set the_title add_filter to show short_URL
- WordPress function, Run using Crontab
- Check if the image size is available and if not use ‘full’ image size
- Tags break custom Excerpt function
- Can set_post_thumbnail be used to remove a thumbnail?
- issue with if/elseif in_array inside foreach loop display only one post
- Change menu based on page template via functions.php
- Adding theme option values as custom body class
- Fail to get the total number of posts
- Function not saving unchecked checkbox
- Removing parent theme CSS without editing parent theme
- Entirely Different Functions.php per Page?
- Problems with functions.php! Error! [closed]
- Output comment_author in array
- Problem with shortcode inside a shortcode
- Hide Author By-Line if After Certain Date
- Is there anyway to force is_singular() to be true when not loading template?
- wp_title() return random number
- Postback redirect through add_action is not triggered
- How to add class dynamically from templates
- How to offset main query without affecting other queries and backend
- ACF Date Form in Custom Admin Field
- How to change form action of wp-login page with a function
- How to add link rel tags on paginated posts?
- How to pass data from a plugin to functions.php
- Function to disable “href” anchor tags that contain “a data-name” on mobile only
- Execute jQuery with custom event listener after successfully add an item to the cart
- WordPress hooks to call a function inside a construct
- WordPress undefined function error on using add_action() in functions.php
- How to make an If Else on Excerpt Filter
- Translation Function missing text-domain [closed]
- Custom taxonomy not refreshing page on add
- Pagination in Search result
- Custom field not updating via functions upon publishing
- disable WP_error: authentication_failed
- Load a Child Theme’s style.css just before the closing tag
- Can’t wrap my head around this function – any help would be appreciated
- Figure inlined width trigger distorted layout
- save_post hook – headers already sent?
- Exclude javascript in certain page url and all following url’s after forward slash
- Changing functions.php and .htaccess files
- Shortcode Variations?
- How to test for a class (from a plugin) in functions.php
- Child Theme not working – CSS gone
- Custom shortcode not being included in content paragraph [duplicate]
- Display post_meta-by_key on product catalogue
- Sessions in word press [duplicate]
- Which template file to edit to edit homepage in Mystile [closed]
- “woocommerce_output_related_products” not working
- woocommerce_sort_product_tabs() expects an array