• Resolved pala55

    (@pala55)


    I’ve been going around and around for weeks. First, let just say that I’m a newbie, so that might explain some of my inadequacies. Secondly, I have also had a couple of small strokes, which makes actually “getting things” a little more difficult … at least in my case.

    I am trying desperately to remove the dates (and “posted on”) and times from my website, since (1) it is not really relevant to the content and (2) I have enormous amounts of downtime due to medical issues.

    The recommended protocol was to create a “child theme”, which from everything I read, seems like the best way to do this. HOWEVER, this is where I lost it. I’m about ready to pull my hair out!

    I have created a “twentyeleven-child” folder on my desktop, where I have included a notepad file with “style.css” in it which includes:

    /*
    Theme Name: twentyeleven-child
    Theme URI: http://helluvahealthsite.com/
    Description: Twenty Eleven Child Theme
    Author: my name appears here
    Author URI: http://helluvahealthsite.com/
    Template: twentyeleven
    Version: 0.1.0
    */

    I did not, however, include the @import url(“../twentyeleven/style.css”); because I wanted to do the enqueue version, which as I understand, would be done by a php file. So, again using wordpad, I did a file called functions.php and put this inside:

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

    }
    ?>

    Next, using the website instructions on Anthony Edward Baldor’s page … I went to Bluehost.com and followed the instructions step by step, except of course, the export line as stated above. When I got to the style.css file, I cut and pasted the above information into the new file in the newly created child theme folder in my bluehost themes folder … whew … and the same for the php file. I next went to my HelluvaHealthSite.com/wp-admin site and looked for the twentyeleven-child, but it did not exist. I checked my work and double checked it … it wasn’t there. So, I deleted the php folder and followed the instructions EXACTLY as per Anthony’s site (in other words, using the @import url(‘../themename/style.css’); AND after checking my wordpress file again, the child theme was there.
    BUT, this is not what I want, so I didn’t activate it. I want the php file, so that I can tackle the ‘date/time’ issue. So, the problem is with the php file (as far as I can deduce anyway).

    First of all, does anyone know how to help. I need “step by step” or I find it overwhelmingly difficult. I also need to know … did I copy and paste the php file to the wrong place – put a separate functions.php (done in notepad)into the new twentyeleven-child theme folder, along with the style.css file. I can’t, for the life of me, figure this out … and it took me so long to do my blog, so I definitely don’t want to screw this up. I also know that this topic has been hashed over time and time again, but I just don’t get it.

    I have also called Bluehost and they cannot help me unless I pay for a service …. can’t afford to do that either!! Ugh!

    Sorry for the rambles, but if anyone can shed some light on this, I would be very grateful!

    Sincerely,
    Pala55

Viewing 6 replies - 1 through 6 (of 6 total)
  • Your code for both style.css and functions.php appear to be correct. Just to be sure, I copied and pasted directly from your message into new files in a folder called twentyeleven-child. I did this in my local development environment, but I can see no reason why it should behave differently on Bluehost. Everything works as it should: the child theme appears amongst my available themes and seems to work correctly when I activate it. I am therefore thinking that you somehow did not have your functions.php file in the right place, but it is impossible to say for sure.

    I suggest that you follow the steps that you did above, then verify using the Bluehost ‘File Manager’ (mentioned in step 4 of the Anthony Baldor post) that you have two files in the wp-content/themes/twentyeleven-child folder, functions.php and style.css. If these are both there and both contain exactly what you wrote above, it really ought to work.

    You might also consider using a text editor that is intended for writing code instead of using either Notepad or Wordpad, neither of which is meant for dealing with PHP and CSS code. Features such as syntax highlighting, for example, can save you a load of bother tracking down little things like missing parentheses and such, and this will become much more important when you begin writing the PHP code to not show the dates on your posts. Assuming that you are on a Windows computer, I generally recommend Notepad++.

    Hope that helps,
    Eric

    Thread Starter pala55

    (@pala55)

    Hi Eric –

    Thank you so much for your quick reply and for your assistance! I can’t even begin to tell you how much I appreciate it.

    I did go back over everything this morning and you’re absolutely right, I had the code correct, but I had made an error in editing. I had done the functions.php file and the style.css file, but when I edited, I opened the file and just deleted what I didn’t want, INSTEAD of using the ‘edit’ button and saving – so of course the changes I made didn’t stick. Duh! Sometime I think you work on something so long, that you can’t even “see it” anymore.

    So, now I’ve got everything I need in the child folder (crossing fingers), EXCEPT for removing the date and time from my posts, which is originally why I started this whole “child theme” thing in the first place. I wonder if you could tell me how I could accomplish this.

    Would I simply edit the style.css file in the child to include the code for the date and time deletion … or would it be put in the functions.php file (child) that would actually load first. For example … my style.css file is shown below – would I simply add to the bottom of it:

    /*
    Theme Name: twentyeleven-child
    Theme URI: http://helluvahealthsite.com/
    Description: Twenty Eleven Child Theme
    Author: my name appears here
    Author URI: http://helluvahealthsite.com/
    Template: twentyeleven
    Version: 0.1.0
    */

    .entry-date { display: none; }

    OR would it be put in the functions.php file – example

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

    }
    ?>

    .entry-date { display: none; }

    Maybe I’m completely too simplistic in my thinking … perhaps, it’s neither. I got this code online – .entry-date { display: none; }, where it also says that after you remove the date, you still have to remove the extra words “posted on”: (and I’m presuming they’re talking about the parent here – quote:

    “To remove the extra words for Twenty Eleven, click on Editor in the admin sidebar and open functions.php. Search the text for “Posted on” and you’ll find this code:

    Twenty Eleven code
    Remove the associated text in your functions.php file to completely remove the date from your posts.

    Delete “Posted on.” You may also want to capitalize “By” so it looks correct on the front-end.”

    In any case, I’m sorry to be so long-winded, but trust me when I say, I do appreciate your patience and help … I really want to do this right.

    I’m also scared to death to press the ‘activate’ button for the child … what if it doesn’t work – will all my sidebars etc. etc. show up when I activate the child?; will everything look the same or will I have a mess on my hands that I don’t know how to fix? … if so, can I just go back to the original parent twentyeleven theme and activate it again?

    Any extra information you could give me would be greatly appreciated. Also, thanks so much for the link to Notepad++.

    Sincerely,
    Fran

    Hello Fran,

    I will try to walk you through the process so that you understand what you are doing as well as doing it…

    In the parent theme folder, themes/twentyeleven/, is a file called functions.php. It is very much more extensive than your child theme’s functions.php, but some of the PHP functions in it can be ‘overridden’ by providing a function of the same name in your own functions.php file.

    Normally in PHP you cannot have two functions with the same name, but WordPress wisely wraps these functions in the parent theme with an ‘if’ statement that looks to see if you already defined a function of the same name in your child theme. Because your child theme functions.php loads before the parent theme functions.php, the child theme’s function will therefore come first and override the one in the parent.

    Looking through the parent theme’s functions.php you will find a function called twentyeleven_posted_on. This is the function that generates the line with the ‘Posted on <date> by <author>’ text. (I am using angle brackets to indicate where the date and author name are inserted.) To override this in your child theme the simplest thing to do would be to copy and paste the original function definition from the parent theme’s functions.php into your own functions.php, then edit away to your heart’s content. Your child theme’s twentyeleven_posted_on function is then used, not the one in the parent theme. Make sense?

    To save you a load of bother, however, I have already done this and tested the result. With any luck you should be able to copy and paste the following at the end of your child theme’s functions.php, and it should just do what you want:

    <?php
    if ( ! function_exists( 'twentyeleven_posted_on' ) ) :
    /**
     * Print HTML with meta information for the current post-date/time and author.
     *
     * Overrides twentyeleven_posted_on in the parent theme
     */
    function twentyeleven_posted_on() {
    	printf( __( '<span class="by-author"> <span class="sep"> Posted by </span> <span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span></span>', 'twentyeleven' ),
    		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    		esc_attr( sprintf( __( 'View all posts by %s', 'twentyeleven' ), get_the_author() ) ),
    		get_the_author()
    	);
    }
    endif;
     ?>

    (I do hope that looks right. I haven’t before tried wrapping a large chunk of code in backticks and pasting it into this support site, and there doesn’t appear to be any way for me to preview my post.)

    (For what it’s worth, I personally do not like the way that the original parent theme’s twentyeleven_posted_on function is written because it contains one line that is very long and not overly easy to edit. On the other hand, it works, and it wasn’t really all that much bother to edit the one super-long line. C’est la vie.)

    You had also suggested changing the CSS (in your child styles.css) so that the date would be ‘display: hidden’, but this is now unnecessary. It seems to me far better simply to not generate the HTML with the date in the first place, especially as you need to override the twentyeleven_posted_on function in order to remove the ‘Posted on’ label anyway. Kill two birds with one stone and all that. This way there is no need whatsoever for CSS tomfoolery because there is no HTML generated with the date in the first place.

    It is worth noting that I used the phrase ‘Posted by <author>’ instead of ‘By <author>’ because the latter didn’t look good to me. You can of course play around with the text if you like.

    So that’s it. Easy peasy.

    As to your question about making changes and being able to return to the old theme if you break your site, you needn’t worry. If you make a change to your child theme and all goes awry, you should be able to re-activate the original twentyeleven theme from the dashboard. You might suffer a brief interruption for anyone visiting your site, of course, but only for the few minutes it takes you to change themes.

    If you truly, truly mess things up and you break your site badly enough that you cannot even get to the admin dashboard, you can always go into the Bluehost ‘File Manager’ and delete the folder with the child theme. WordPress is then smart enough to use one of its built-in themes, which will then allow you to start over from something stable. Because all of your posts and comments and whatnot are stored in the database, not as files within the wp-content folder, everything important should remain intact whenever you change from one theme to another.

    As you can see, I can ramble on as good as anyone…

    I do hope that helps, and happy child-theming!

    Cheers,
    Eric

    Thread Starter pala55

    (@pala55)

    Hi Eric –

    OMG … Wow! … and from the bottom of my heart, thank you! You’re the best!

    I know that for those of you who work around a computer, “code” and “wordpress” much of the time and have the expertise to make changes easily, this may seem “over the top”, but I was literally in tears after loading my child theme. It was ABSOLUTELY,POSITIVELY PERFECT!

    I had been going in circles on the internet, day after day, trying to piece together enough information to successfully make the necessary changes I wanted to the site and was overwhelmed by the plethora of information out there. However, despite my great passion for continued education, it also became very frustrating, confusing and stressful not only to comprehend and understand the various directions given, but scary to dabble in an area that I was so under-qualified and unsure about.

    Trust me, I also know that the majority of you have put in enormous amounts of time, while continually building your skill sets … and believe me, someone at my level of learning is so grateful for your time and patience – your expertise is invaluable to those who are just beginning!

    And yes, I had approached others, but was basically told that they didn’t have time … or given another link to check out (as in “duh”), which to some degree I respect as well – everyone is busy and I totally understand and get that.

    I’ve also been to sites where a question by a relative “newbie” is answered with disrespect and a stance of “superiority”, so I was cautious about joining this or any other forum to ask my questions. I couldn’t have been more wrong! This is exactly where I needed to be and I am so grateful!

    I now understand a little bit more about the process – okay not 100% there yet :-), but very happy to have learned from such a gracious and wonderful person … someone who has made me want to continue my quest to learn “code” and how it works on my blog/site. Some of us really do need the “step by step” directions to get there!

    Eric, you couldn’t have been more kind or more patient and as I said … and again, from the bottom of my heart, thank you, thank you and thank you. Did I say THANK YOU! Kindness is always the way forward and you have been so much more than kind!

    With a grateful heart,
    Sincerely, Fran

    Hi Fran,

    It was my pleasure to help, and thank you for the very kind words. Having spent many years working in the speech sciences, and having taught many aspiring speech therapists, I am all too aware of the difficulties faced by those who have suffered strokes as well as various head injuries.

    Rest assured that you did all of the hard work. After all, you had figured out the vast majority of what needed to be done to develop your child theme on your own. This is no small feat for anyone, let alone for someone with no little or no background in such things.

    Keep up the blogging, and I wish you the best of success with your new and improved website.

    Best,
    Eric

    Thread Starter pala55

    (@pala55)

    Hi Eric –

    Well, I thought I had everything figured out re my child theme and the site looked absolutely wonderful, but I’ve just noticed that the “adsense ads” (3 random ads that would match the theme of the site – ‘health and wellness’) – that were placed in the left hand sidebar, about half way down – after the current news articles, are all missing. Would you please be kind enough to look at my site once again … HelluvaHealthSite.com and see what you think.

    I do have some sort of “script” there that I can’t fully see … it almost looks like … “this webpage can’t be displayed” … but I’m not 100% sure because I can’t see it in its entirety.

    Did I need to add something else in my child theme style.css file that would encompass these ads or has something else changed that I’m not aware of? Is there code that would help solve this problem. Any assistance you could give would be greatly appreciated.

    Also, I do need “step by step” instructions. 😀

    Sincerely, Fran

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Child Theme Confusion – Bluehost, WordPress’ is closed to new replies.