Support » Fixing WordPress » understanding template hierarchy

Viewing 4 replies - 1 through 4 (of 4 total)
  • typical concern.
    just understand that the ‘content-‘ php files are not Templates, they are Template Parts! Read this.
    basically a subset of the WP template to populate contents. and there is no hard and fast rule to use “content”name for php files. rename then to say madivad.php, madivad-single.php, madivad-search.php, etc.
    and change your loop to get_template_part( 'madivad', 'single ); etc. just saying.. using the name “content” for files confuses people initially.

    remember that apart from single, page, search, etc, you also need the loop for post-formats() like aside, image, video, etc. so keep madivad.php generic. and drilldown further and be specific say in madivad-aside.php.

    read theme dev here.

    So content.php (and it’s sub-templates?? content-single.php, content-search.php) are independent of and not related to (get_)the_content()?

    the_content(), the_excerpt() etc are simple WP functions, nothing more.
    ‘The Loop’ is the heart and soul of WP. All your DB fetching and CMS operations get done here. imagine the number of times WP_Query gets called and with the kinda parameters everytime a WP webpage is accessed in the world.
    the WP API get_template_part works something like this:

    <?php
    if ( file_exists('content-single.php') ) :
      include 'content-single.php';
    else :
      include 'content.php';
    endif
    ?>

    i recommend understandng the loop properly – Read This.
    and ofcourse, the templates once more.

    it’s sometimes the simple statements that bring home a point.

    Thanks very much shadez.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘understanding template hierarchy’ is closed to new replies.