• Resolved aday09a

    (@aday09a)


    After creating a child theme and also new file for functions.php, the site didn’t display. But after deleting the new functions.php, everything went back to normal. However, I noticed that images in posts are no longer displayed on the homepage. They display only after clicking on the post itself.

    Error message: PHP Fatal error: Cannot redeclare ridizain_content_width() (previously declared in /home3/abujarev/public_html/smallbusinessguidefornigeria/wp-content/themes/ridizain-child/functions.php)

    Thanks in advance for a solution

Viewing 14 replies - 1 through 14 (of 14 total)
  • Theme Author Brian Harris

    (@zgani)

    Hello Aday09a,

    Re: “Images not displaying” – That will depend on a number of things and without seeing a live link or more details on the setup it would be difficult to pin point the cause.

    Check: Do images show up correctly when the parent theme is active?

    As for the fatal error – that indicates that you copied the functions.php from the parent theme in to your child theme and that is not the way to do it. Only copy functions you want to change in to your child theme’s functions.php and bee sure to change the function handler.

    In the error above: ridizain_content_width() should have been changed to something like ridizain_child_content_width().

    NOTE: functions.php in a child theme is only for adding new functions or for modifying parent theme’s functions as indicated above.

    Please give more details on the images issue and I’ll do my best to assist you.

    Regards,
    Zulf

    Thread Starter aday09a

    (@aday09a)

    Hello Zulf and thanks for your reply.

    I have checked. The images do not display on the parent theme either. Please note that this non-display applies to the homepage only. The images do not display only on the homepage and here is the link. http://www.smallbusinessguidefornigeria.com

    However, when you click on the post, it displays the images in the post.
    here is the link for that: http://www.smallbusinessguidefornigeria.com/what-you-should-know-before-you-register-your-business-2/

    I have removed the content of the functions.php in the child theme because it was preventing the page from displaying at all. I had hoped that the site would fall back on the contents of the functions.php in the parent theme. But since I have the same problem using the parent theme, I will appreciate your help.

    Thanks

    Theme Author Brian Harris

    (@zgani)

    Both links are returning a 404 page not found error.

    Do you have any posts and pages published? Please link to a live post.

    Is Jetpack photon module enabled? If so then disable it.

    Have you flushed your permalinks? Go to Settings permalinks and re-save the settings.

    Thread Starter aday09a

    (@aday09a)

    Here is a link to a live post. http://www.smallbusinessguidefornigeria.com/5-things-your-hair-salon-consultant-will-never-tell-you/

    Jetpack Photon is not enabled.

    Thank you

    Theme Author Brian Harris

    (@zgani)

    Thanks for the link.

    It looks like the parent theme’s excerpt function is not being picked up for some reason – that function is formulated to show images and videos in the excerpts.

    Are you using your own custom excerpt function or a plugin to generate the excerpts?

    Thread Starter aday09a

    (@aday09a)

    the only widgets i have on the site are ‘ridizain recent posts’ and ‘ridizain ephemera’

    Theme Author Brian Harris

    (@zgani)

    OK, you are going to have to a do a little bit of coding here.

    In Ridizain’s functions.php (line 257 to 292) is the function for the excerpts – copy the entire section to your child theme’s functions.php.

    Then change all instances of ridizain & $ridizain to your child theme’s slug name i.e. ridizain_child and save. Check the site to see if that resolves the problem for you.

    Zulf

    Thread Starter aday09a

    (@aday09a)

    It didn’t work.

    I copied

    }

    /**
    * Register Lato Google font for Ridizain.
    *
    * @since Ridizain 1.0
    *
    * @return string
    */
    function ridizain_font_url() {
    $font_url = ”;
    /*
    * Translators: If there are characters in your language that are not supported
    * by Lato, translate this to ‘off’. Do not translate into your own language.
    */
    if ( ‘off’ !== _x( ‘on’, ‘Lato font: on or off’, ‘ridizain’ ) ) {
    $font_url = add_query_arg( ‘family’, urlencode( ‘Lato:300,400,700,900,300italic,400italic,700italic’ ), “//fonts.googleapis.com/css” );
    }

    return $font_url;
    }

    /**
    * Enqueue scripts and styles for the front end.
    *
    * @since Ridizain 1.0
    *
    * @return void
    */

    function ridizain_ie_support_header() {
    echo ‘<!–[if lt IE 9]>’. “\n”;
    echo ‘<script src=”‘ . esc_url( get_template_directory_uri() . ‘/js/html5shiv.js’ ) . ‘”></script>’. “\n”;
    echo ‘<![endif]–>’. “\n”;
    }
    add_action( ‘wp_head’, ‘ridizain_ie_support_header’, 1 );

    function ridizain_scripts() {
    global $wp_styles;
    // Bump this when changes are made to bust cache
    $version = ‘1.0.18’;

    I pasted into functions.php of ridizain-child and changed all instances of ridizain this way:

    <?php

    //
    }

    /**
    * Register Lato Google font for Ridizain.
    *
    * @since Ridizain 1.0
    *
    * @return string
    */
    function ridizain_child_font_url() {
    $font_url = ”;
    /*
    * Translators: If there are characters in your language that are not supported
    * by Lato, translate this to ‘off’. Do not translate into your own language.
    */
    if ( ‘off’ !== _x( ‘on’, ‘Lato font: on or off’, ‘ridizain_child’ ) ) {
    $font_url = add_query_arg( ‘family’, urlencode( ‘Lato:300,400,700,900,300italic,400italic,700italic’ ), “//fonts.googleapis.com/css” );
    }

    return $font_url;
    }

    /**
    * Enqueue scripts and styles for the front end.
    *
    * @since Ridizain_child 1.0
    *
    * @return void
    */

    function ridizain_child_ie_support_header() {
    echo ‘<!–[if lt IE 9]>’. “\n”;
    echo ‘<script src=”‘ . esc_url( get_template_directory_uri() . ‘/js/html5shiv.js’ ) . ‘”></script>’. “\n”;
    echo ‘<![endif]–>’. “\n”;
    }
    add_action( ‘wp_head’, ‘ridizain_child_ie_support_header’, 1 );

    function ridizain_child_scripts() {
    global $wp_styles;
    // Bump this when changes are made to bust cache
    $version = ‘1.0.18’;

    ?>

    Thread Starter aday09a

    (@aday09a)

    Sorry, this is what I changed it into:

    <?php

    //
    }

    /**
    * Register Lato Google font for Ridizain_child.
    *
    * @since Ridizain_child 1.0
    *
    * @return string
    */
    function ridizain_child_font_url() {
    $font_url = ”;
    /*
    * Translators: If there are characters in your language that are not supported
    * by Lato, translate this to ‘off’. Do not translate into your own language.
    */
    if ( ‘off’ !== _x( ‘on’, ‘Lato font: on or off’, ‘ridizain_child’ ) ) {
    $font_url = add_query_arg( ‘family’, urlencode( ‘Lato:300,400,700,900,300italic,400italic,700italic’ ), “//fonts.googleapis.com/css” );
    }

    return $font_url;
    }

    /**
    * Enqueue scripts and styles for the front end.
    *
    * @since Ridizain_child 1.0
    *
    * @return void
    */

    function ridizain_child_ie_support_header() {
    echo ‘<!–[if lt IE 9]>’. “\n”;
    echo ‘<script src=”‘ . esc_url( get_template_directory_uri() . ‘/js/html5shiv.js’ ) . ‘”></script>’. “\n”;
    echo ‘<![endif]–>’. “\n”;
    }
    add_action( ‘wp_head’, ‘ridizain_child_ie_support_header’, 1 );

    function ridizain_child_scripts() {
    global $wp_styles;
    // Bump this when changes are made to bust cache
    $version = ‘1.0.18’;

    ?>

    Theme Author Brian Harris

    (@zgani)

    You copied the wrong code.

    This is what you need…

    // Ridizain Custom Excerpt
    function ridizain_child_trim_excerpt($ridizain_child_excerpt) {
      $raw_excerpt = $ridizain_child_excerpt;
      if ( '' == $ridizain_child_excerpt ) {
        $ridizain_child_excerpt = get_the_content(''); // Original Content
        $ridizain_child_excerpt = strip_shortcodes($ridizain_child_excerpt); // Minus Shortcodes
        $ridizain_child_excerpt = apply_filters('the_content', $ridizain_child_excerpt); // Filters
        $ridizain_child_excerpt = str_replace(']]>', ']]>', $ridizain_child_excerpt); // Replace
    
        if (get_theme_mod( 'ridizain_child_feed_excerpt_length' )) :
    		$ridizain_child_feedlimit = get_theme_mod( 'ridizain_child_feed_excerpt_length' );
    	else :
    		$ridizain_child_feedlimit = '85';
    	endif;
        $excerpt_length = apply_filters('excerpt_length', $ridizain_child_feedlimit); // Length
        $ridizain_child_excerpt = wp_trim_words( $ridizain_child_excerpt, $excerpt_length );
    
        // Use First Video as Excerpt
        $postcustom = get_post_custom_keys();
        if ($postcustom){
          $i = 1;
          foreach ($postcustom as $key){
            if (strpos($key,'oembed')){
              foreach (get_post_custom_values($key) as $video){
                if ($i == 1){
                  $ridizain_child_excerpt = $video.$ridizain_child_excerpt;
                }
              $i++;
              }
            }
          }
        }
      }
      return apply_filters('ridizain_child_trim_excerpt', $ridizain_child_excerpt, $raw_excerpt);
    }
    remove_filter('get_the_excerpt', 'wp_trim_excerpt');
    add_filter('get_the_excerpt', 'ridizain_child_trim_excerpt');

    I’ve already made the changes for you in the above code – simply copy and paste in in to your functions.php.

    Can I ask why have you chosen to use a child theme as opposed to using Ridizain as it is?

    Thread Starter aday09a

    (@aday09a)

    Thanks for your help. I copied the code you sent. Images still do not display on the homepage.

    I have created a child theme because I read here https://codex.wordpress.org/Child_Themes that modifying a theme is best done using a child theme. That way, I don’t get to lose my changes when I update the theme.

    While we are still at this, could you please tell me how to remove ‘author’ from posts. Thanks for your patience.

    Theme Author Brian Harris

    (@zgani)

    Cool glad you are following best practice 🙂

    Could I ask what files you currently have in your child theme and if any modifications have been made to them?

    If at all possible, could you pen a note of what exactly you wish to achieve with the child theme i.e. what mods you want and drop in in to my DropBox here: http://wpdefault.com/file-share/ – it will give me an idea of what is going on and hopefully be able to add some of the mods in for you as well as advise you better.

    Thread Starter aday09a

    (@aday09a)

    author.php
    content.php
    functions.php
    genericons.css
    header.php
    ridizain-child.sidebar.php
    style.css

    modified are:

    style.css (adding -child in order to be able to create the child theme)

    functions.php (the modif you did for me today)

    the other files there contain the same file contents of the parent theme.

    Theme Author Brian Harris

    (@zgani)

    Still not able to replicate the issue – if you can drop me the files I’ll be more than happy to look at them and offer you a solution.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Image Not displaying After Creating Child Theme’ is closed to new replies.