How to remove the h1 tag for the particular page in page.php file

I want to remove the h1 tag for the particular page because my page.php file coded is displaying the title for all the pages but want to remove h1 tag(title) for particular page.

code for displaying the titles for all the page:

Read More
<?php
/**
 * The template for displaying all pages.
 */
get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<section id="subbanner">
          <?php the_post_thumbnail(); ?>

            </section>
             <section id="subcontent">
<section id="service">
            <aside class="frame">

                                    <h1><?php the_title();?></h1>
                        <?php the_content();?>


            </aside>
            </section>
               <?php endwhile;?>
<?php get_footer(); ?>

so i customized to my requirement for removing the h1 tag for particular page using if else statement by finding the page_id of the particular page but this doesn’t work properly.

<?php function remove_heading_for_particular_page() {
                if ( is_page('page_id=1757') ) {?>
                           <?php the_content();?>
                        <?php }else{?>
                                    <h1><?php the_title();?></h1>
                        <?php the_content();?>
                        <?php }?>
 <?php }?>

could anyone help me to find solution for removing the h1 tag for particular page.

Thanks in advance.

Related posts

2 comments

  1. You are not using is_page() properly. You have to use it like is_page( 1757 ) instead of is_page('page_id=1757').

    So your if condition will be as like :

    <aside class="frame">
                           <?php if(!is_page( 1757 )) { ?>
                            <h1><?php the_title();?></h1>
                           <?php }  ?>
                            <?php the_content();?>
    
    
      </aside>
    

    Hope it helps you.

  2. is_page() function takes page id directly instead of string.

    <aside class="frame">                    
    
                       <?php  if ( is_page( 1757 ) ) { ?>
    
                                 <?php the_content();?>
    
                       <?php } else{ ?>
                                    <h1><?php the_title();?></h1>
                                    <?php the_content();?>
                       <?php }?>
    
     </aside>
    

    Hope this code will help you 🙂

Comments are closed.