• Resolved chillindays

    (@chillindays)


    Hi Ben,

    I’m just trying to create a function that places a brief passage of text at the end of every post except certain ones I choose and be able to update these when necessary.

    I am pretty much a total noob when it comes to coding so I’m probably way off. But this is what my research led me to do doing. Only problem is it breaks my site (test site) every time I do it no matter what I try.

    So I go to function.php and paste in the following code:

    <?php

    if ( is_single() && !is_single( array( ’example-page-one’, ’example-page-two’ ) ) ) {
    echo “There’s only one product I truly recommendHere’s how it works…”;
    }
    ?>

    The idea is to have that display as if I’d written it at the end of every post, bar a select few I choose for it not to display on. The ‘heres how it works’ is supposed to be the anchor text to my main offer page.

    Is the code correct?
    Where does it go exactly in the Ignite theme?

    Many thanks for your help Ben, cheers!

    Tim

Viewing 3 replies - 1 through 3 (of 3 total)
  • Theme Author Ben Sibley

    (@bensibley)

    Hi Tim,

    Thanks for choosing Ignite!

    There are a few things that need to be updated. This code has the logic for when to show that text, but it needs to be hooked up with the excerpts, so it know where/when to be displayed.

    I went ahead and wrote this code for you, and put it into a “child theme”. A child theme is basically a future-proof way of customizing a WordPress theme. If you modify Ignite’s functions.php file, you’ll lose your changes next time you update Ignite. With a child theme, you can add your customization and keep it through updates. Here’s the download link:

    Click to download

    You can install the child theme via the Appearance menu like a regular theme.

    Before you install it, there are a few changes that need to be made. First, on line 9 of the child theme’s functions.php file, the slugs/IDs need to be added for the posts instead of the placeholder text “example-page-one” and “example-page-two”. Secondly, I don’t know the URL the text should link to, so I left the “href” empty in the link element. You’ll just need to plug in the URL there to add the link.

    Once those two changes are made you can upload the child theme, and the customization will be complete!

    Let me know if you need anything else or have more questions about this customization.

    Thread Starter chillindays

    (@chillindays)

    Awesome thanks Ben you’re a champion. Much appreciated!

    Theme Author Ben Sibley

    (@bensibley)

    You’re welcome, glad I could help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Inputting a new function’ is closed to new replies.