• Let’s say I want to exclude a category from the loop on the author page of my child theme using:

    query_posts($query_string . '&cat=-5');

    Other than this loop modification, no other changes are needed.

    Does wordpress provide a way to modify the loop but still use the parent template, or do I have to overwrite the entire author.php just to add this loop modification?

Viewing 1 replies (of 1 total)
  • Are you sure you mean a child theme?

    With a child theme the only files that are in the child themes folder are the ones we want to change, so a basic child theme a few lines on code in the style.css and a screenshot image.

    Lets use twenty ten and your scenario, lets say we only want to add the condition and not change the post output.
    1. copy author.php to the child theme and add the posts query
    WordPress now loads the Childs author.php and not the parents.

    If we wanted to change the post layout as well.
    1. copy author.php and loop.php to the child theme
    2. re-name loop.php to loop-author.php
    3. Make any changes to author.php and save
    4. Make any changes to loop-author.php and save

    WordPress now loads the Childs author.php, loop-author.php and not the parents files.

    If this was the only change we wanted for our theme, then the child themes folder would only have four files, all the rest are inherited from the parent theme.

    author.php
    loop-author.php
    screenshot.php
    style.css

    HTH

    David

Viewing 1 replies (of 1 total)

The topic ‘Modify loop in child theme without overwriting parent template?’ is closed to new replies.