Question

I'm trying to create a custom page template by copying page.php, changing its name to smth different and playing around with it.

I would like to remove the title in my custom page template - (not on a specific page, but in the whole template!).

Reading here and there I see that the solution seems to be removing this:

<h2>” title=”<?php the_title(); ?>”><?php the_title(); ?></h2>

Unfortunately, I don't see that line in my custom template, this is how the code looks:

<?php
/*
Template Name: Links
*/


get_header(); ?>


<?php while ( have_posts() ) : the_post(); ?>

    <?php get_template_part( 'content', 'page' ); ?>



<?php endwhile; // end of the loop. ?>

<?php get_footer(); ?>

What should I remove here?

Was it helpful?

Solution

You are almost there, just find the PHP file, which starts with content-, edit it, and remove the the_title() function.

Why? Well, because this line of code get_template_part( 'content', 'page' ); seeks for a PHP file in your theme's folder, which starts with content-.

EDIT: The function will do a PHP require() for the first file that exists among these, in this priority:

  • wp-content/themes/your_theme/loop-index.php
  • wp-content/themes/your_themechild/loop-index.php
  • wp-content/themes/your_theme/loop.php
  • wp-content/themes/your_themechild/loop.php

So check those files too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top