WordPress.org

Forums

Customizr
[resolved] functions.php on childtheme : can't acces to admin panel (12 posts)

  1. Math_le_fou
    Member
    Posted 1 year ago #

    Hi everybody.

    I'm using this fantastic Custumizr Theme for somes websites, using childtheme, but i now meet an issue with adding a functions.php on my childtheme.

    When adding funtions.php, website is ok and functions works fine, but i can't acces to the admin panel.

    My website : http://hebergement-responsable.fr/biomod/

    The code of functions.php is :

    <?php
    /* Remove the ... from excerpt to change to readmore*/
        if( ! function_exists('name_of_function') ) {
    	function change_excerpt_more()
        {
          function new_excerpt_more($more)
            {
            // Use .read-more to style the link
              return '<span class="continue-reading"> <a href="' . get_permalink() . '">... >> Lire la suite</a></span>';
            }
          add_filter('excerpt_more', 'new_excerpt_more');
        }
        add_action('after_setup_theme', 'change_excerpt_more');
    	}
    
    /** reduce excerpt to 25 words */
    
    if( ! function_exists('name_of_function') ) { 
    
    function new_excerpt_length($length) {
     return 25;
    }
    add_filter('excerpt_length', 'new_excerpt_length');
    }
    ?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

    I'm not an expert on php and i'm sure it's just a little code tips i don't have.

    Could someone please help me ? (sorry for bad english ;-))

  2. d4z_c0nf
    Member
    Posted 1 year ago #

    Mmm works fine here.
    By the way, technically but unrelated to the issue you're experiencing, you have to replace ('name_of_function') with the actual function name, to make that check have a sense, so

    if( ! function_exists('change_excerpt_more') ) {
    	function change_excerpt_more()

    and

    if( ! function_exists('new_excerpt_length') ) { 
    
    function new_excerpt_length($length) {
  3. Math_le_fou
    Member
    Posted 1 year ago #

    Thank's for your answer.
    Website works fine because i delete functions.php in the chidtheme.
    I changed code with your advices, but still got an issue. Website works fine but can't acces to admin panel an white page with :

    Warning: Cannot modify header information - headers already sent by (output started at /home/heber619/public_html/biomod/wp-content/themes/Biomod/functions.php:1) in /home/heber619/public_html/biomod/wp-admin/post.php on line 235
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/heber619/public_html/biomod/wp-content/themes/Biomod/functions.php:1) in /home/heber619/public_html/biomod/wp-includes/pluggable.php on line 1121

    An idea of where does the issue comes from ?

  4. stephencottontail
    Member
    Posted 1 year ago #

    In your child theme's functions.php, make sure the starting <?php block is the very first thing in the file. There can be no blank lines or spaces before that.

  5. d4z_c0nf
    Member
    Posted 1 year ago #

    And this happens just when you have that code in your child-theme functions.php?
    Mmm, please paste the whole content of your child-theme functions.php using this and copy here the pastebin link.

  6. Math_le_fou
    Member
    Posted 1 year ago #

    Yes it just appear when i use a functions.php on childtheme, perfecly working else.
    Thanks for your help

    http://pastebin.com/HDBc3KJe

    @Stephen : wou're wright but still doesn't works

  7. d4z_c0nf
    Member
    Posted 1 year ago #

    Mathu I'm sorry, I cannot reproduce your issue :/
    I thought about the same thing Stephen suggested..
    Does this happen with whatever code you put there?

    edit:
    already read this?
    http://codex.wordpress.org/FAQ_Troubleshooting#How_do_I_solve_the_Headers_already_sent_warning_problem.3F

  8. acub
    Member
    Posted 1 year ago #

    Remove the

    ?>

    from the end of your code snippet. This might be the cause.

  9. Math_le_fou
    Member
    Posted 1 year ago #

    @ Acub : WEAAAAAAAAHHHHHHHHHH !!!!! Thanks a lot it works perfectly !

    @d4z_cOnf : Thanks a lot for your help too !

    It's just the first time i ask some help in the forum, and you make me save a website project !

    Un Grand Merci (in french) for your help !

  10. d4z_c0nf
    Member
    Posted 1 year ago #

    This is weird, never had problems with ending ?>. It could depend on the php.ini settings I guess..
    Glad you solved and thanks to acub :)

  11. acub
    Member
    Posted 1 year ago #

    It is generally advisable and considered good coding practice not to exit php mode before end of file of "pure" php files (that are to be included in other php files). The reason for this is quite obvious, to avoid errors like the one above: sending empty headers that can cause a WSOD.

    Namely, the problem in Math's functions.php was that he had an empty line, space or tab after ?>.

  12. d4z_c0nf
    Member
    Posted 1 year ago #

    Yes I know, what I meant (but I expressed it very badly :)), is that I have not hat that kind of problem with ?> + spaces after, hence my guess about php.ini. Though I had an issue with the feed validator in that case.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic