How to execute filter code in wordpress page

112 views Asked by At

I have an issue i have put this html code

<a href="http://somepage.com/gulfstream-iii/" class="info">Read More</a>

But wordpress output gives me this html on the page when i inspect the element.

<p><a href="http://somepage.com/gulfstream-iii/" class="info">Read More</a></p>

I want to remove the paragraph tag from code which is automatically included by wordpress some one suggest me to try this code.

remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

i am adding this script in function.php file it works for me but it create other problem remove paragraph tag on other page that make the content worse, so want a solution to run this code by using specific page with condition but when i put this code in page.php i get no result.

if(is_page(19)) { 
    remove_filter( 'the_content', 'wpautop' );
    remove_filter( 'the_excerpt', 'wpautop' );
}

Somebody help me to solve this issue?

1

There are 1 answers

0
AudioBubble On BEST ANSWER

This code will only work if put the code before the page loop.

if(is_page(19) || is_page(461)) { 

remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
 }
            get_template_part( 'loop', 'page' );


            ?>