Mystery <p></p> element in code

I have 2 pages whose layout is based on the same global layout.

Only for a reason I don’t understand, a <p> element is added to one of the two pages. But it is not containing in the database of that specific page!

Page without the element:
Bildschirmfoto 2022-09-20 um 15.41.48 Bildschirmfoto 2022-09-20 um 15.43.57

Page WITH the <p> element
Bildschirmfoto 2022-09-20 um 15.41.23
Bildschirmfoto 2022-09-20 um 15.41.09

Regnalf

Hey @Regnalf,

The other page must have HTML syntax errors. I checked the source code and there’s an opening <p> tag before the start of the content.

image

Please check your page for syntax errors. Try removing all the elements on the page and then reintroducing them one at a time.

Thanks.

It must happens somewhere else, i’ve checked the pages but i couldn’t find the <p> element.
The issue happens somewhere between the page layout and the page content.

I gave you login credentials in the secure note, but please be aware, this is i live site!

Hey Regnalf,

It would be hard to find the syntax error. Please try deleting elements in your page. To safely do that, save your page as a template using the Template Manager then load the template in a test page.

Thanks.

Deleting the elements unfortunately does not change the behavior when I add them back later.

Furthermore, at the moment I get the error that when I save the layout or the page, I get a red error message “Page/Layout could not be saved”. Despite the fact that the change to the page was saved anyway!???

Also the <p> element is not present when I edit the page in Cornerstone Editor!

Hello @Regnalf,

I have investigated your issue. I doubled check the layouts and the page in the builder. I even did a search and replace process to find the mysterious <p></p> tags. I did not find it as well. It may seems that it came from a 3rd party plugin. Can you please do the following:

Kindly let us know how it goes.

I’ve deactivated all the plugins, removed all child functions php code and the the <p> element still shows up!
I’ve deleted the pro cornerstone cache and also the total cache and even with the deactivated total cache plugin the <p> element still shows up!

Hey @Regnalf,

It looks like you did not test removing elements. I removed the 3rd Section of your page and there’s no more <p>. Take a look at the test page (see secure note).

image

There’s no header and footer in the test page because if they’re active in the layout, you can’t save the page.

The page not saving is a separate issue and it looks like it has something to do with the Header and/or Footer. When I created the test page, I had to disable the Header and Footer in the test Layout so the page could be saved. Please create a separate thread for this once the issue in this thread is resolved.

The problem of Section 3 is the Global Block with the content DC

image

Your layout already uses The Content and you also outputting the_content inside it. That works but it will have consequences like the <p></p> tag.

Please remove your Global Block or you need to think of an alternative way to display the content in Section 3.

Thanks.

Thanks for the info, I had actually tested that though, but maybe I just missed it.

I am now using custom code to get the content and it is working as it should.

add_filter( 'cs_dynamic_content_hs', 'hs_dynamic_content_hs', 10, 3);
function hs_dynamic_content_hs ( $result, $field, $args)
{
	global $post;
	
	switch ($field)
	{
		case 'post-content':
			if ($post != NULL)
			{
				$result = get_the_content();
			}
			break;
		
	}
	
	return $result;
}

Still it would be nice to use the {{dc:post:the_content}} from you though. It would also be interesting to know why this extra <p></p> tag is created???

The last changes I made on the page could be saved without any problems. If the problem occurs again I will create a separate ticket.

Hey @Regnalf,

Thank you for your feedback.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.