unwanted p tags when adding shortcode in search results archive
-
I created a custom archive for search results. I use Relevanssi and Toolset Views.
To make it work with Relevanssi I followed this topic: https://wp-types.com/forums/topic/custom-search-relevanssi/.
I added some code to functions.php of my theme. This makes highlight search term work.
// highlight keyword with relevanssi // https://wp-types.com/forums/topic/custom-search-relevanssi/ function highlight_keyword_func($atts, $content) { $content = do_shortcode($content); if(isset($_GET['s'])){ $content = relevanssi_highlight_terms($content, $_GET['s']); } return $content; } add_shortcode( 'highlight-keyword', 'highlight_keyword_func' );
This is how I implemented the shortcode in the Toolset Views WordPress Archive:
[wpv-layout-start] [wpv-items-found] <!-- wpv-loop-start --> <ul class="wpv-loop js-wpv-loop"> <wpv-loop> <li> <h3>[wpv-post-link]</h3> <p><em>[wpv-post-date]<br>Filed under: [wpv-conditional if="( '[wpv-post-type]' eq 'post' )"]News[/wpv-conditional][wpv-conditional if="( '[wpv-post-type]' ne 'post' )"][wpv-post-type show="plural"][/wpv-conditional] [wpv-conditional if="( '[wpv-post-type]' eq 'post' )"] - [wpv-post-taxonomy type="category" format="name"][/wpv-conditional]</em> <br /> [highlight-keyword][wpv-post-excerpt][/highlight-keyword] </p> </li> </wpv-loop> </ul> <!-- wpv-loop-end --> [/wpv-items-found] [wpv-layout-end]
You can view the result I have so far here: http://staging.impel.eu/?s=birds
Problem: the excerpt in the search results is wrapped in <p></p> tags. However, I did not add these to my template in the Views WordPress archive. These tags are generated by the highlight_keyword shortcode. I temporarily removed this shortcode and then the p tags disappeared.
How can I resolve this? How can I get rid of these tags?
The page I need help with: [log in to see the link]
- The topic ‘unwanted p tags when adding shortcode in search results archive’ is closed to new replies.