3.5. Example: Seeking for the Post Title in the Puzzle

Assuming we need to find the element where the post title is (in most cases a H1 element) to construct our selector, so that we can customize it in single posts with a default template, here’s the path we are to follow.

Step 1: Opening content.php

singular.php told us to open content.php.

Please take a time to match the file with the following screenshot; it’s going to help you understand all the elements in the PHP file.

Lines from content.php in the screen

Did you find the title of the post? No…

But, it’s at one click away: at the beginning of the file (line 20), it calls for another piece: entry-header.php.

Step 2: Opening entry-header.php

And here it is! Take a look at line 45; there is a condition…

  • if is “singular” (a post, a page), the title will be display inside an h1 element with the class .entry-title.
  • else (such as post titles’ in the archives’ pages), the title is going to be inside a h2 element, with the same class plus one more: .heading-size-1.

To Bear In Mind

Using h1.entry-title, is going to affect the title of posts and pages, on all templates; and we may not want that. This is why knowing how the theme is structured is so important.

Hence a few questions arise:

  • Which are the selectors for the post types posts and pages;
  • Which are the selectors for each of the templates?
  • How do we combine the selectors for post types and the ones for templates?

In the following section, which is our last stop on our discovery journey, we are going to follow a “tree.”

This puzzle we began to analyze, is going to appear under the “Developer Tools” as a tree, and it’s going to give us almost everything we need.

Laly York. Neurodivergent Gen-X writer / B.Ed. / Lawyer. Writing, coding and taking pics. From Jupiter, living in a soap opera; flying on the web with three blogs.


Any thoughts?