Try this.
function search_excerpt_highlight() {
$excerpt = get_the_excerpt();
$keys = implode('|', explode(' ', get_search_query()));
$excerpt = preg_replace('/(' . $keys .')/iu', '<ins class="search-highlight">\0</ins>', $excerpt);
echo '<p>' . $excerpt . '…' . supralegal_read_more_link() . '</p>';
}
function supralegal_auto_excerpt_more( $more ) {
return '';
}
add_filter( 'excerpt_more', 'supralegal_auto_excerpt_more' );
function supralegal_read_more_link() {
return ' <a href="'. esc_url( get_permalink() ) . '" class="read_more">' . __( 'Read more', 'supralegal' ) . '</a>';
}
Related Posts:
- Pretty permalinks for search results with extra query var
- custom naming of search permalink /search/
- Rewriting search permalink
- Search result permalink
- Changing search URL to something other than “search”
- Custom permalink for search and pagination
- How to make /search/ without parameters not return a 404?
- Is there a link parameter that will show me all my published pages?
- encoded search terms with %20
- How to add specific phrase to end of search url
- Read more block is appending /#more-{post_id} to the link
- Cannot make custom search permalink to work in a fully custom theme. Search string $_GET[‘s’] is always empty
- Replacing + sign to – in wp Search Permalink
- WordPress search seems to look into permalink (which is bad)
- Search page Paginations not working
- Pretty Permalink for Search Queries Not Working
- Permalink / sub-template issue
- Search points to /search/?s=KEYWORD instead of /search/KEYWORD
- get_posts displaying wrong permalink for “continue reading” link
- Non english characters in search bar
- Changing permalinks gives me 404 errors on nginx
- Strange permalink issue: can’t rename /company-2/ to /company/
- Using $_GET variables in the URL?
- Removing leading zeros from custom permalink structure
- Move WordPress to subdirectory, keep ALL URLs
- WordPress permalinks Yahoo hosting(no .htaccess allowed)
- How do I turn off 301 redirecting posts (not canonical)?
- How can I include a query string with get_permalink
- Permalink: postname EXCEPT for blog
- %tag% in permalink not working
- How to assign a Permalink to a Function
- How to identifty post from its URL in 404 page?
- Rewrite rule never matching
- How to get blog id from permalink?
- Custom url for a single page
- Rewrite-Rules not working on a vhost, everything goes to index.php
- Date archive permalink modification
- Using ‘Primary Category’ in URL
- Changes to permalink structure results in 404 error for all pages other than home
- Filter string like a slug
- I need a custom permalink for my website
- How to link to “most recent” document in the Media Library?
- Permalinks not working
- Problem with wordpress links on a live site
- Why wordpress multisite root site showing blog prefix by force?
- Permalink change redirects by WordPress [duplicate]
- page nested 3 levels deep shows 404
- Removing /author/ slug from URL gives 404
- changing permalink for custom template in posts of a certain category
- Force wordpress to display page with same url structure as categories
- Why the “Permalink” option is not showing in the “Settings”? [closed]
- is there a way to add the post URL to the results of fselect facet in Facetwp plugin?
- NGINX serve WordPress from sub-path fails with 404, how to fix?
- Redirect /%year%/%monthnum%/%day%/%postname% [closed]
- How to get the full URL of the current page and change domain of it?
- Custom permalink structure: /%custom-taxonomy%/%post-name%/ (without CPT slug)
- How to get functions.php work with postname permalink?
- How can I get this custom post type permalink structure? %custom_post_type%-%taxonomy%-%term-postname%
- get_permalink returning site home url instead of the url of slug being passed
- Host frontpage via example.com and everything else via example.com/blog
- Dynamic Custom Permalinks
- 404 error using Meta for Permalink rewrite
- WordPress suddenly changed all links to example.com/example.com/
- How to handle paging/pagination with a custom permalink?
- Environment independent way to link to certain pages on frontend
- Custom URL rewrites for templates
- Relative links in Gutenberg
- Why is my RSS feed not working?
- Convert single apix to dash in permalinks
- How to remove the link of an image on WP 4.2
- How to get raw unwritten querystring
- WordPress Permalink
- Can not manually change the permalink of a post in the EDIT secion
- How to change permalinks to show categoryname/post-name?
- Post with no tag permalink problem
- What permalinks do I use in the redirection
- WordPress’ «post name» setting broken
- Keep wordpress basic permalink preferences
- .htaccess to redirect to a wp page
- My WP homepage works, but the other pages don’t when accessing from out side of my network
- How do I use the same Tag slug for different Tags?
- Permalinks are not working in WordPress
- CPT links error: each one links to next one further along in the list
- Logging in to installation in subdirectory renders broken dashboard (no CSS, broken links)
- Woocommerce product page 404 not found
- WordPress and NGINX – permalinks are not working with ending slash
- Get value from URL with different types of parameters
- a way to support totally different url structure
- How to hide slug numbers with htaccess
- Permalink not working
- When using number in url it is redircting to same page but when using character it redirects to 404
- Once redirected by Rewrite rules, how can WordPress know the page?
- Webdav with permalink in WordPress v3.3.1
- Why not working /%postname%/ with ajax serverinterval?
- Custom Permalink Base
- Appending a variable to RSS link url
- My wordpress site must be being affected by outside sources [duplicate]
- Page and post auto links
- how to make follow?
- Custom Permalink Structure For a Specific Category