• Resolved highaltitudearcher

    (@highaltitudearcher)


    Hello,

    I’m relatively new to wordpress, but not new at all to coding.

    I’m trying to understand how child themes work (or don’t as the case may be). I have used a child theme to extend a theme I purchased, and for the most part all is well.

    What I want to do next is to develop a filter to remove posts from the “latest news” page. I found all the necessary documents about query_posts and The Loop.

    It would appear that the relevant code is in page.php, and yet, when I copy the page.php from the parent to my child, and add in some markers (e.g. a comment, so that I can prove my child is getting executed), I can tell that the code is still coming from the original parent theme.

    So my question is this: What incantation do I need to do (I guess in functions.php) to register the child version of pages.php as being more important than the parent version?

Viewing 6 replies - 1 through 6 (of 6 total)
  • What you did just proved that your theme’s “Latest News” page doesn’t come from page.php.

    Try view source on the Latest News page and see the body class (CSS class name assigned to <body> tag), it will tell you what template it uses, and then you can figure out how to override it in your child theme.

    Body Class
    https://codex.www.ads-software.com/Function_Reference/body_class

    Template Hierarchy
    https://developer.www.ads-software.com/themes/basics/template-hierarchy/

    Thread Starter highaltitudearcher

    (@highaltitudearcher)

    Ah, that sounds like a handy tip.

    Here’s the content of the body-class:

    blog logged-in admin-bar custom-background boxed-layout uniform-typo customize-support

    Here’s the rub: nothing I see in that list screams to me about what file to find the layout responsible. I ran through a grep of all files in the template directory and found nothing that really stands out.

    blog: found in lots of places (makes sense for a blogging engine)
    logged-in, admin-bar: wordpress internal
    custom-background, boxed-layout: css tags used to trigger specific layout features on all pages
    uniform-typo: something to do with typography configuration
    customize-support: something to do with the customizer the theme enables.

    The page in question is an empty “page” type which is marked as “news”, and the content is magically replaced with the “latest entries” list — just can’t figure out where the magic happens.

    According to the template hierarchy you reference (which I studied at length last night), the render path ought to be:

    Single page >> static page >> page template >> custom | default template >> $custom.php? (what’s this) >> (page-$slug.php (none such) >> page-$id.php (none such) )? >> page.php (not picking up my edits) >> singular.php (none such) >> index.php

    Just looking at that flow, it seems that everything ought to go through page.php. I also copied the single.php and made the same edits (I guess that’s the other primary template for postings?) but still found no changes in the ouptut.

    Is that all the body class list? If so, theme has custom function filtering WP body class function. Usually we will see blog class with home or blog class with page.

    The page in question is an empty “page” type which is marked as “news”, and the content is magically replaced with the “latest entries” list — just can’t figure out where the magic happens.

    This is a normal behavior when we set a page as blog listing page (Post Page), and the other specific page as static Front page
    https://codex.www.ads-software.com/Creating_a_Static_Front_Page

    In this case your “Latest News” page is using home.php template.

    Thread Starter highaltitudearcher

    (@highaltitudearcher)

    Yep, that’s a direct copy-paste from the class list.

    There is no home.php in the parent theme. There is a home-page.php, which I think (not really sure tho) is used to specify the index layout (which is significantly different than the default).

    The theme I’m using as a parent does not name another parent — is there a home.php that is implicitly referenced somewhere?

    Thread Starter highaltitudearcher

    (@highaltitudearcher)

    Update: there is no file named “home.php” in my wordpress installation.

    Thread Starter highaltitudearcher

    (@highaltitudearcher)

    Ah ha! Found it. It’s being rendered from index.php.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘page template call sequence?’ is closed to new replies.