• I’ve been trying to get RSS feeds to display entire posts on external site embeds, and someone kindly pointed me to twentyeleven_excerpt_length in functions.php. I changed it from the default “40” (words) to “500”, which is more than I’ll ever need, and it works fine – posts are no longer truncated.

    However, for that change to survive the next theme update I’ll need to move it to the child theme, of course. The comment-text in functions.php tells me how, but I don’t know the file layout well enough to know if I’m doing it slightly wrong.

    I had a go, anyway. Here’s the entire text of functions.php in my child theme, it doesn’t currently work.

    <?php
    
    function new_excerpt_length($length) {
    return 500;
    }
    add_filter('excerpt_length', 'new_excerpt_length');
    
    ?>

    I know this is probably a really simple formatting problem – I’ve just no idea where to start, or what obvious thing I need to include.

Viewing 6 replies - 1 through 6 (of 6 total)
  • That part looks right. Something else must be wrong.

    Does your child theme show as the current theme in the dashboard?

    You will need your style.css file in child theme as well
    http://codex.ww.wp.xz.cn/Child_Themes#The_required_style.css_file

    Thread Starter swarmofbees

    (@swarmofbees)

    Sorry for not replying before, I got this thread muddled with another one and thought it had been closed. *is new here*

    Vtxyzzy: Yes, it does. In all other aspects, my child theme is active and functioning fine.

    Govpatel: I’ve got that, it was the first thing I had. I’ve had no hitches with the child theme until this part.

    Well, all in all, it’s nice to know there’s nothing egregiously wrong with my code, but it makes its current nonworking state all the more puzzling. :O

    vtxyzzy

    (@vtxyzzy)

    I think the filter you are using only applies to Posts, Pages, etc, not to feeds.

    Can you do what you want by going to Admin->Settings->Reading and choosing ‘Full text’ radio button for ‘For each article in a feed, show’?

    Thread Starter swarmofbees

    (@swarmofbees)

    *nod* That was one of the first things I tried; I only tried monkeying around with functions.php when none of the in-admin-screen settings seemed to do anything.

    I get the impression that with this kind of thing, there’s endless contradictory instructions overwriting each other; but functions.php seemed to be the one all the others listen to. It works, in the parent theme; I’m just concerned with moving the relevant bit of code to the child theme, so updates won’t wipe it and stick me back with the 40-word limit.

    vtxyzzy

    (@vtxyzzy)

    If that works in the parent theme, it should work in the child theme as well. Something else may be wrong.

    To be sure that the function is being called, put in a debugging statement like this:

    <?php
    
    function new_excerpt_length($length) {
       print_r('<h2>DEBUGGING new_excerpt_length</h2>');
    return 500;
    }
    add_filter('excerpt_length', 'new_excerpt_length');
    
    ?>
Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Functions.php in child theme – need syntax’ is closed to new replies.