1

I have tried searching, and tried a few options, but I'm not able to remove the H1 / title / Underscore for specific pages.

I don't want use CSS. I would like to remove it via functions.php or in content.php.

I'm not good in PHP, so the Codex didn't help me too much.

I need something like this:

if > page slugs / IDs > do not display H1/ title

Can anybody help? Thanks.

  • You can remove the h1 from any template that has it like index or page or single php, but why would you want to? You're going to seriously hurt your SEO without an h1 title in there. I suggest creating an absolute position that takes the <h1> off the page but not out of the document. – Nathaniel Flick Jul 29 '16 at 15:49
  • I need add own H1. – Gore Jul 29 '16 at 17:37
  • Your problem can be soved by using is_page() function as suggested by Devender Narwal. Have you tried with that function? Have you understood how you can use this function in your page.php? Please tell your progress from posting question here to till now since you got two answer, How much they helpful to you and what problem you have left with you. – Rishabh Jul 30 '16 at 4:58
  • Well, I have tried a lot of codes from Google, but nothing worked. As I said Im not good (still learning) in php, so Im asking for exact help. I developed one code, that I use in function.php for calling JS for specific pages. But I dont know how finish it for H1 problem: if ( is_page('xxxx', 'xxxx') ) { – Gore Jul 30 '16 at 6:17
  • I highly recommend you not remove H1's from your templates. It's unsemantic and bad for your SEO. – Nathaniel Flick Jul 30 '16 at 6:29
1

The way I would do this is to create a separate page template that lacks the H1 code, and then manually select that template (in the Page Attributes box on the page editor screen) for each desired page.

  • Hello @RobSterling - Welcome to the WordPress Development community! Please refrain from asking questions in answers - such information is typically best discussed in comments on the original question (though I understand that you may not be able to post comments quite yet). – bosco Jul 29 '16 at 15:27
  • OK, removed the question I had posted after answering his question broadly. – Rob Sterling Jul 29 '16 at 15:50
  • It is clever idea Rob! But I think, code will be easier. – Gore Jul 29 '16 at 17:36
0

WordPress has the predefined function is_page(), which looks like this:

is_page( int|string|array $page = '' )

If the $page parameter is specified, this function will additionally check if the query is for one of the pages specified.

It returns true or false, depending on whether the query is for an existing single page.

You can find more details in the documentation.

  • Hi Devender, welcome to WPSE. While this might answer part of the question, it doesn't answer the whole question - specifically, how to not actually display the title. Are you able to edit your answer to expand? – Tim Malone Jul 29 '16 at 8:27
  • Hi Time, Now it is looking professionally and now onwards i will keep in mind that answer should be in that way thank you – Devender Narwal Jul 29 '16 at 9:57
  • One plus vote for more specific answer .-) thx – Gore Jul 29 '16 at 17:39

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.