Archived topic
Still the custom page template
6 replies · Started by Rui on May 11, 2020
Hi there,
I'm trying to develop a page using a custom page template that I had support here:
https://generatepress.com/forums/topic/a-brand-new-post-with-a-custom-style/
But something happens (maybe related to the style sheet) and it looks different than I expected.
What I want is this: https://www.zenite.nu/vida
But what I got (with my custom page template) is: https://www.zenite.nu/a-trilha-da-vida/
I can't understand because when I view the source code of both pages they look the same, except by the tags (in the second one)
<article id="post-ID ...
<div class="inside-article">
<div class="entry-content" itemprop="text">
that include the entire document, but it doesn't seem to be the cause of this problem.
Moreover, in that page, the first tag ( <main> ) is nested inside paragraph tags <P> that I don't know where it came from!
Could you give me some help on what may be going on?
I figure out!
The problem was the automatic paragraph tags (from WP itself).
I used a filter:
remove_filter ('the_content', 'wpautop');
and now it´s all right!
Glad to hear that - looks great !
Thank you, David!!
Do you know why WP does this on some pages, but - apparently - not on others?
Are there any implications in applying this filter to the entire site?
Hi there,
That filter is applied to everything that runs through the_content() filter. It adds paragraph tags automatically to your text so you don't have to.
There could definitely be some bad things that happen if you remove it site-wide, but I don't even think it's used on pages using the block editor anymore, which is good.
You can always target a page template:
add_action( 'wp', function() {
if ( is_page_template( 'your-page-template.php' ) ) {
remove_filter( 'the_content', 'wpautop' );
}
} );
Thank you -
As always, you guys help a lot!
Glad we could help :)