Adding Code snippets to functions.php when using a child theme?

I have a chunk of code i need to add to the function.php. i'am using a 2011 child theme, which does not have a functions.php file. Should i just create a functions.php file for the child theme and add only the code snippet to it, or the entire 2011 function.php + the code snippet.

I have tried it both ways and get the blah blah blah in public_home/blah blah/ not; here let me get you the error message!

Fatal error: Cannot redeclare twentyeleven_setup() (previously declared in /home/tithi/public_html/domain.com/wp-content/themes/twentyteleven-w4f/functions.php:53) in /home/tithi/public_html/domain.com/wp-content/themes/twentytwelve/functions.php on line 77

Thanks!

  • shawng
    • Site Builder, Child of Zeus

    You can always create a file and add it to your plugins directory that way it is always active even if you change the theme.

    example:
    create a file my-important-plugin.php

    code:

    <?php
    /*
    Plugin Name: My required plugins
    Plugin URI: http://yoursite.com/
    Description: functions that I want active on all themes
    Author: Your name
    Version: 1.0.0
    Author URI: http://yoursite.com
    */

    Then below that code, simply add in the gravityform code from the articles. Upload the file to your plugins folder, then go and activate the file just like any other plugin.

    the advantage is now this code will work even if you change themes. Super simple.

    Here is a link to a completed file that works http://pastebin.com/M46Cc5GX

  • Mark Wallace
    • Learn-ing-er

    @shawng
    Testing is looking good, it showed one item sold out, i will be testing this, and if it works on all the fields like the tutorial said i have 50 Rep Points for you!

    Also
    If you can tell me how to make images expand in html so that they can be added to the page using the HTML editor in the WP page kitchen sink I will give you another 50 Rep Points! I would like it to be about half the size of a business card and expand out to be the full size of a business card when hovered, and want to be able to link it to a website when clicked. I have been looking at tutorials and only find expandable hidden content HTML.

    Also when i find members like you who help people in the "Above and Beyond" way you just did, i stalk them and Reward them for helping other members as well. It is in hopes of building a stronger community! :slight_smile:

    @Tom
    I will check out your suggestion since it was my original question, and will be good for singles site "Less Plugins" and give you some points too!

    But the plugin will be great for multisites and multiple themes! AWESOME!!!

    Keep an eye on shawng "I see a new life time member in the works" :wink:

  • Mark Wallace
    • Learn-ing-er

    Also
    If you can tell me how to make images expand in html so that they can be added to the page using the HTML editor in the WP page kitchen sink I will give you another 50 Rep Points!

    keep in mind there will be several thousand instances of different business cards, all different and all linking to different sites. I am not aware of how to do or how difficult this is, but i have not made much progress, and spent the better part of the day with it. so the points can be negotiable! :slight_smile:

  • Mark Wallace
    • Learn-ing-er

    Man @Tom I am in crunch time on a few things, and i have gotten side tracked with this gform snippet and the html boxes "All of which can be done after the fact" BUT its that not being able to accomplish something syndrome, i have been at this for about 2 weeks, and have black rings under my eyes from a lack of sleep, DARK rings; i look like a raccoon lol and my other 6/7 is starting to get worried ans are becoming naggy!

    @Tom @shawng

    I am geeting ultiple problems, it works with functions.php and tyhe plugin for two fields, but once there is a field that is not populated corrctly the form will not recover, even after clearing the catch, and deleting cookies. It also is not reconizing new categories, s it my be the latest Gravity update. I am gong to have to rest for a bit, and explore this more.

    Will post back after a nap, and fresh install of WP older GForm version and testing. If it a Gform update issue then i will go ahead and give out some points.

    Tom! I do want my trophy back, but i am still member until 2023 hehehe they gave @Maxaud like 2018 or something! He said does that mean they don't think i will live that long ROFL Night everyone/or morning here! :0

    @shawng I like the dove! I think we may be brothers! :slight_smile: I know i was asking/believing for the answer you gave! I will ask his blessing upon you! SO BE BLESSED! << If that confuses you, just know you will be blessed!

  • shawng
    • Site Builder, Child of Zeus

    it's 530 am my time so to tired to do anything this morning.

    Send me a link to an example of what you want the expanding cards to do when you wake up and I'll take care of it. I know how to do what your asking, but it is much easier to have a 'real' example to work with so I can simply paste in the css rules.

    The general idea is you are going to use a hover element on the css

    general concept....

    .some-unique-frame-for-content img { max-width 50% }
    .some-unique-frame-for-content img:hover { max-width 100% }

    That idea works if you are able to start with an image that is 2x the size needed for filling the container. Otherwise instead of max-width, you could use the width itself.

    Honestly if you give me some example links, it will be easier. I should be awake in 6-7 hrs.

    Obviously we're brothers, as your post was the only one I have really answered all week. laying here waiting for an ftp job to finish uploading and I saw your post, was easy to answer, so there ya go.. ya got ur answer :slight_smile:

  • Mark Wallace
    • Learn-ing-er

    @shawng
    Sorry for the late reply, i slept for almost 10 hours, and feel like i could sleep another 10. lol

    Ok! i started another thread with a member who previously helped me with the basic code to understand the HTML and CSS of this. It was a few weeks ago before i got caught up in the Gform quest.

    I Know he has a lot going on at the moment, and i gathered you are pretty busy as well. I do not want to waste two people time who have their own work to do.

    So If you would check out the following thread it will help keep the topics relevant for future members, and also a lot of what i am wanting to do is already posted there. I just updated with the criteria i'am looking for.

    The other member is Maxaud "Dustin" he has been a real blessing to me and others in the community with code snippets! So if you are willing to check out the thread. that would be great! I don't have example links, but i will make some the best i can and post them there! probably in about 2 hours. Have to take care of the household before i get to involved with this!

    https://premium.wpmudev.org/forums/topic/maxaud-i-lost-the-link-you-gave-me#post-295909

    Thanks @shawng

  • shawng
    • Site Builder, Child of Zeus

    I saw the other thread. I'll let him take care of the css questions as I don't want to jump into a huge support thread. Mostly I was just doing a quick drive by to offer some quick advice. From what I gather your understanding of CSS is nowhere near far enough along that I can answer the question in a few lines. I just don't have the bandwidth to take on a longterm project like that one. I am glad to hear that you got the plugin working though. I can't comment on the code itself as I don't use it, but the general concept will work for anything. Simply take any code that people suggest you add to your theme functions file and add it to that new plugin file. That way when you change themes, your custom code doesn't change. I wish you the best of luck.

  • Mark Wallace
    • Learn-ing-er

    Adding the code to an empty child theme functions.php works, and adding the code to a plugin works, BUT the @#*&^%! code has a bug in it, and the website it is on seems more concerned with the traffic it brings their site than they are with someone wasting several days on it. Other wise they would have fixed it, or removed it per my request that they remove it until its fixed as not to waste someone else's time!

    may as well post on a website, "FREE GOLD" and not mention "Just find it and pan it yourself" hehehe :stuck_out_tongue:

    As for the hover boxes Maxaud is working through it, As @Shawng was kind enough to state,

    From what I gather your understanding of CSS is nowhere near far enough along that I can answer the question in a few lines. I just don't have the bandwidth to take on a longterm project like that one.

    ROFL At least i think the "bandwidth" part was a joke! lol

    Thanks Tom!
    Be Blessed!

  • shawng
    • Site Builder, Child of Zeus

    @MTB1701
    As to the problem with the snippet, have you asked David to look into it? I didn't see any comments by you in the link you provided to the snippet on his site.

    I can say that I have worked with David many times in the past and he is an absolutely fantastic guy. I've found him to be tremendously helpful and actually a lot of fun to work with.

  • Mark Wallace
    • Learn-ing-er

    @shawng

    Sometime post do not show on a website while awaiting moderation!

    I would not prefer to mention anyone by name in such a case, or their business, that is a blessing blocker! I have spoken highly of them in another thread.

    As far as the guy you are speaking of, he seems very helpful, on numerous threads that i have read. I do not wish to give him a bad name! Look up and see if there is an edit option for that post please.

    If you want to see my post on that website i can take snip Shots for you and send them via email, but i do not know what that would accomplish, I just decided to move on to another method.

    Now that i reread your post i see i did include the website earlier. :disappointed: @Tom could you delete that link for me. I don't want to be responsible for giving anyone a negative outlook from one incident!

    Thanks Fella's; You can close this Tom, I have another option!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.