• twenty eleven theme.

    I can use CSS in child theme no problem. But for php functions, sometimes it does not work if I modify php functions in child theme.

    I know the difference: CSS in child theme will rewrite CSS in parent theme, so there is no conflict. But php in child theme won’t replace the parent function. sometimes it gives me headache.

    e.g., I want to modify a php fuction in content.php:
    <?php the_content( __( ‘Continue reading <span class=”meta-nav”>→</span>’, ‘twentyeleven’ ) ); ?>

    I new a file content.php under child theme directory. and
    put a line of redefinition, like:
    <?php the_content( __( my new fuction…) ); ?>

    It always prompts error when I load the page. Syntax is no problem coz it runs well if I just modify it in parent file.

    Another example, if I want to add some script in header.php, like:
    <script type=”text/javascript” src=”whateveritis.js”></script>

    I do the same thing in header.php in child theme, but it gets me error.
    the script runs no problem if I just add it to header.php in parent theme.

    How to solve this? thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • What is the exact code that you have for
    <?php the_content( __( my new fuction...) ); ?>

    I know that it’s not that, so there is a very good chance that you are doing something wrong in there.

    Thread Starter techill

    (@techill)

    My new function is my customized function. It works because I already tried in original content.php. My conern is: it does not work if I put it in child theme’s content.php. I just wanna do the modification in child theme’s content.php instead of the orginal content.php, so I wont lose any customization once I do the WP update in the future.

    So the key point is:
    if I want to use my php fuction in child theme, how I can bypass the same name function in parent theme? If I can, there is no conflict.

    Use the same function name as in the parent’s theme. If the parent is child-friendly, the child’s version will take precedence.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘how to modify a php function in child theme without conflict?’ is closed to new replies.