Looking at the documentation for the get_the_excerpt
filter, we can see that it receives the WP_Post
object representing either the current post or the post which was passed in to the get_the_excerpt()
function call.
Thus,
function q_excerpt_custom( $excerpt, $post ) {
if ( get_post_type( $post ) == 'post' ) :
$excerpt_custom = '<a class="card-permalink" href="' . get_permalink( $post ) . '" rel="nofollow"> HA HA HA </a>';
return $excerpt_custom;
endif;
return $excerpt;
}
add_filter( 'get_the_excerpt', 'q_excerpt_custom', 10, 2 );
Related Posts:
- Only show read more text when when wp:post-excerpt meets excerptLength
- How to remove the Theme Customization Button from the dashboard and themes options page?
- What filters are applied to the_content function?
- Change admin bar to default:off
- How to modify an image block in Gutenberg WordPress 5?
- Edit srcset and sizes attributes in Gutenberg image, cover and gallery – blocks
- wp_get_attachment_image_attributes not working for me
- Twenty Eleven home page show only excerpt
- How to call the_excerpt() with tags or the_content() as an excerpt?
- Display a different theme for not logged-in users
- Run shortcode before filters
- Add class to before_widget for all widgets with a dropdown and a counter
- How to Auto Approve Comments on a Specific Page?
- Get password when user registers and save it sha1 into database
- Passing variable in hooks and filter
- Formatting ?
- How to programmatically bring back “excerpts” field in post editor in WP 3.1+
- How to hide and content from auto-generated excerpts?
- the_excerpt() not showing manual excerpt for Pages
- Which theme foundry has clean coded themes, where code is poetry [closed]
- WordPress nav_menu_css_class theme filter is not being called
- customizing the_password_form filter
- WordPress Genesis Child Theme Filter divs
- Change file name from wp_generate_attachment_metadata
- Don’t understand why theming is so strange and twisted [closed]
- Simple way to get two language WP site
- get_page_template returning nothing
- Bold letters inside excerpt [closed]
- Highlight “Show all” item in wp_list_categories
- When trying to override plugin’s function by theme, my filter executes two times, I want it to run only a single time
- How to move the the_excerpt’s read more link to another div
- Menu item added in wp_nav_menu_items filter is never highlighted
- Should I use add_filter for functions in function.php of the theme?
- buddypress: how do i make the group description excerpt shorter?
- the_excerpt(); tag not working
- Disabling automatic teasers
- Pass variable to hook. Its possible?
- How to make the excerpt_more filter apply to the actual post excerpt?
- How to obtain a reference to the_excerpt() from custom loop
- Exclude read more in the_excerpt [closed]
- Custom get_the_excerpt() only works on first post
- excerpt() shows different result between remote and localhost(development environment)
- WordPress taxonomy and archive custom class
- Filter categories used with Custom Structure Permalink
- How to wrap all titles generated by Gutenberg “Heading” block with tag
- How can I optimize this code? [closed]
- Replace single_template filter with what for default posts?
- How to escape html generate by a loop
- Unique design inside a specific category’s url
- How to rotate every letter in a title
- How to disable thumbnail filter for a specific template part or image size?
- CSS class on last post in loop ( custom query )
- Where do you add code in custom fuctions so it works on a specific page?
- adding class to excerpt
- How to change footer credit text in Twenty Twenty One theme with a hook?
- Use a filter on menu items that have children
- How to code custom special page
- Modify available templates (in dropdown)
- Get Post’s Excerpt Without the Wrapping tags and the Read More link
- Single.php the_excerpt loads same as the_content not loading read more line
- tiny_mce_before_init: ‘exact’ => true has no effect
- How to conditionally add a wp_filter
- Filter didn’t work on content class (hybrid_post_attributes)
- How to set default values for edit_post_link() in my theme?
- first excerpt fine, subsequent post excerpts shift to the right instead of displaying vertically [closed]
- Tiny MCE custom styles, and preview in the backend
- content filter (add_filter) for category description?
- matisse theme show excerpts not whole content
- Related Post Category Filter
- Pagination don’t work with active filters
- How to register dynamic settings in WordPress Customizer?
- How to make force_balance_tags balance comment tag
- WordPress wp_get_current_user returning blank values until refresh
- Alternative solution for script_loader_tag?
- Alt header logo and link for specific pages
- WordPress Twenty-Fourteen: How to Remove Home Page Header Image from Other Pages
- Make a custom field in admin post.php read only
- New theme HTML5 Support for Search in WordPress 4.4
- Hook in parent theme Menu function
- How do I remove p tag *insertions*? Disabling `wpautop` removes manual tags
- How to add custom nav_menu_css_class to certain menu only?
- How to manipulate wordpress template tags’ output
- what is do_action(); in wordpress? [duplicate]
- Filter URL and shortcodes from the_excerpt
- Suppress the_content filter in a nested loop
- apply_filters to featured image
- Add rel to all images in a post
- Website Developer has gone missing! How to gain full access of your code from a WordPress website?
- Is there any filter or action hook to remove layout classes from appearing in my templates?
- WP “optimizing” PNGs into thumbnails 5X larger than originals – FIX
- optimized PNGs 5X larger than originals
- Menu items description? Custom Walker for wp_nav_menu()
- How to define and link full path to css located at a random folder on header.php
- Sizing screenshot.png without losing aspect ratio
- Software for WordPress Theme and Plugin Development? [closed]
- When to use is_home() vs is_front_page()?
- What is the preferred way to add custom javascript files to the site?
- Get the blog page URL set in Options
- How to create .pot files with POedit?
- How do I get the theme URL in PHP?