1
<?php the_content(); ?>

When we use the above the content is published like this →

<p>Content is published</p>

If I want to later this HTML and instead of <p></p> I want that <h3></h3> should be there. Is that possible?

4

The wrapping <p> is applied by a filter called wpautop. You can disable this filter and wrap the content in your desired wrapper, but it's not really recommended.

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

Now you can wrap your content in a DIV for example:

<div><?php the_content(); ?></div>

But notice that this filter is applied to more than just beginning and the end. It's applied to paragraphs and galleries, etc. Disabling it might not have the desired effect.

  • Slightly Confused with this → Disabling it might not have the desired effect. Can you Please explain? You man it will affect where it is not needed? – The WP Novice May 19 '18 at 9:34
  • What I meant was, this filter also applies to each paragraph. If you disable it, you will get somehow the raw output you see in the text tab of TinyMCE editor, which will not style well. You can give it a try, publish a text with rich content ( paragraphs, images, etc ) and then disable the filter. See how it affect a lot of things. – Jack Johansson May 19 '18 at 9:38
  • I got your point. Instead the best will be leave it as it is and use some CSS to make the paragrapgh font larger at a spcialized location where needed. – The WP Novice May 19 '18 at 9:41
  • Exactly. Wrapping the whole content in a <h3> tag is not a good idea, instead you can wrap the_title() inside that. – Jack Johansson May 19 '18 at 9:42
  • wrap the_title() inside that. → How? – The WP Novice May 19 '18 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.