How to implement specific php codes in child theme

Hi. (Please mark thread as private)

1. I have created a functions.php file and placed it in the child theme. It works. The only code in the child´s functions.php as of right now is:

<?php add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );

}

I wanted to add a function that sends users directly to a promotion when they click a featured promotion image. I asked the author of the theme for help, and he replied:

Open file functions.php and add these two lines

(see image)

From what I could tell, the code was:

<a href="<?php echo get_permalink( $code->ID ); ?>">
</a>

so I opened the functions.php in child theme and wrote it like this:

<?php add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );

}
<a href="<?php echo get_permalink( $code->ID ); ?>">
</a>

Upon saving changes, my website broke and whitescreen of death appeared.

How do I implement this correctly? My initial thought when backtracing my steps was to copy the functions.php from parent theme, and add the code only in the child theme´s functions.php file. However, codex.wordpress.org guide under "using functions.php" says:

Do not copy the full content of functions.php of the parent theme into functions.php in the child theme.

I have no idea what to do...

2. The second change I wanted to do was to show the coupons on the homepage, the same style as the coupons showed at top 20 with the colored buttons.

What it looks like now
How I want it to look.

The author of theme replied;

Open file includes/code_list_loop.php and copy this part

Image showing example

Then open file functions.php and paste it here

Image showing example

and ended the thread with:

In the copied part substitute get_the_ID() with the $code->ID

I am very sorry for not adding pure code, and linking to images. This is due to the theme´s author and the level of support provided. Short, blunt answers with links to printscreens which leaves me with more questions than answers.

Is there anyone, anyone at all who understand what I am trying to achieve here, and are willing to help me implement the above in my child theme?

Thank you very much for your time!

  • Vinod Dalvi

    Hi @Dan-Louis,

    Welcome to the WPMU Dev community and thank you for your question.

    As requested i have marked this thread as private.

    How do I implement this correctly? My initial thought when backtracing my steps was to copy the functions.php from parent theme, and add the code only in the child theme´s functions.php file. However, codex.wordpress.org guide under "using functions.php" says:

    Just create functions.php file in your child theme and don't just copy it from the parent theme as unlike style.css, the functions.php of a child theme does not override its counterpart from the parent. Instead, it is loaded in addition to the parent’s functions.php. (Specifically, it is loaded right before the parent’s file.) therefore there will be duplicate code causing issues.

    Find more information about it on the following page.
    http://codex.wordpress.org/Child_Themes#Using_functions.php

    (see image)

    Which image?

    Have you missed to attach the image?

    I wanted to add a function that sends users directly to a promotion when they click a featured promotion image. I asked the author of the theme for help, and he replied:

    Could you please share me the page URL where the featured promotion image is getting displayed and also tell us what promotion you want to send so that we can help you to achieve it?

    Please also share us the reply as it is that you got from the theme author.

    Upon saving changes, my website broke and whitescreen of death appeared.

    This is because you are adding HTML code directly in the PHP file which is wrong.

    2. The second change I wanted to do was to show the coupons on the homepage, the same style as the coupons showed at top 20 with the colored buttons.

    What it looks like now
    How I want it to look.

    To achieve this try adding the following CSS code in the style.css file of your child theme or add it in your site using the following plugin.

    http://wordpress.org/plugins/simple-custom-css

    body.home .filters {
    margin-left: 0;
    width: 100%;
    }
    body.home .filters  .btn-group.btn-categories.form-control,
    body.home .filters form.form-horizontal {
    float: left;
    width: 540px;
    }
    body.home .filters  .btn-group.btn-categories.form-control {
    margin-left: 35px;
    }

    Best Regards,
    Vinod Dalvi

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.