Question about best practices on tweaking Genesis

Community Forums Forums General Discussion Question about best practices on tweaking Genesis

This topic is: not resolved

This topic contains 11 replies, has 4 voices, and was last updated by  braddalton 12 months ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #52949

    Joan
    Participant
    Post count: 6

    Hi Everybody!

    I’m developing my first Genesis Theme, and I have a question about how to tweak it. I want to do some changes on the homepage. Should I use functions.php using is_front_page conditional or should I just put the code on the front-page.php file?

    I test it and it works both ways, but I would like to do it the right way.

    #52964

    David Chu
    Participant
    Post count: 1315

    Hi Joan, and welcome.

    I would say there’s no right answer. It’s entirely a matter of taste. My bias is towards the function method, because it’s very tidy. Typically, when I make a custom child theme, there are just 2 files, styles.css and functions.php. I like having all my machinations in one place, and that’s what functions.php offers. I can still get as wild as I want with layouts and such.

    Yet others like to have bunches of template files. It seems to me that these are often people who already have WP theme development experience, so this way is more familiar to them. So maybe going the template file route will be a gentler intro for you until you know all Genesis hooks and filters well.

    I was asked to make extensive changes on a site which was built on Genesis, but manages to use almost no Genesis functionality whatsoever, and there are dozens of template files! As a result, it’s hard for me to find anything without resorting to a text scanner. :-) IMO, this site may have been better off being built in something like Underscores or Twenty Twelve if they were going to go the route of not using any Genesis functions.

    That’s my take, I’m sure others would differ.

    Enjoy the system!
    Dave


    Dave Chu · Custom WordPress Developer – likes collaborating with Designers

    #52966

    Joan
    Participant
    Post count: 6

    Hi David!

    Thanks for your answer. The functions file sounds better, because everything it’s in the same file, but some studiopress child themes use front-page.php or home.php. That’s why I’m wondering if it’s the best way. Also, Bill Erickson use this method.

    Thanks for your point of view, I really appreciate it!

    Joan!

    #53014

    braddalton
    Participant
    Post count: 8835

    One of the only advantages of using the home page template is if you want sections of widgets. Example: Epik, Modern Portfolio etc.

    You could still do this in functions with the 3rd parameter plus you can style the entire home.php template differently to the rest of your site.

    I would use a home page template in this case.

    I’ve found the easiest way to create your own custom home page is to use code from an existing child theme and tweak it to fit your theme. Big fan of the Pro Plus Package as all the code works perfectly on any Genesis child theme.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #53038

    Joan
    Participant
    Post count: 6

    Hi Brad,

    What about other template files, like category-id.php or archives.php? Do you recommend using conditionals on functions.php or use the template files? Is there any PHP performance issue in doing it like that? Or in the number of queries?

    Let me put an example. Something easy, like remove the entry title on home if you are using an static page. I can use a conditional like that on functions.php:

    add_action('get_header', 'child_remove_page_titles');
    function child_remove_page_titles() {
    if ( is_front_page() )
    remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
    }
    

    That action trigger my child_remove_page_titles() allways (on any single page and post). But the function will do nothing at all, unless it’s on the frontpage (but there it is, an “useless” function on 99% of pages and posts).

    The other option is create a front-page.php template file and put in it:

    remove_action( 'genesis_entry_header', 'genesis_do_post_title' );

    It seems cleaner to me, doesn’t it? Moreover, I’m not calling my function on every single page and post. Does it make sense?

    That’s why I wonder if it’s better do it like that. Again, it’s my first genesis child theme and I don’t know if it’s better, I’m just checking I’m going it the best way.

    Thks for all your opinions!!

    PS: Oh, and sorry for my English, I’m from Barcelona, I’m doing my best!

    #53052

    David Chu
    Participant
    Post count: 1315

    Joan,
    Barcelona, que bien. ¡Su ingles es mejor que mi español! Y supongo que habla catalá. :-) De todos modos….

    I’ll say that despite my preference for functions.php, even in complex home pages with extra widgets, I do use template files for Custom Post Types, and possibly archives, etc. if the layout is different enough. There are some situations where it’s easier to program with an extra template file.

    My bias towards functions.php is influenced by another thing…. I am very handy with CSS, so I will often change an area’s layout using that alone. For many, it will be easier and faster to use different HTML instead of the CSS approach, so they will enjoy templates more.

    Here’s another thought – if someone were considering moving a theme away from Genesis (¡Ay, que horror!), it may be easier to convert a template file (as opposed to functions.php) to “regular WordPress” because of the familiar appearance.

    Your question about performance (speed) is a good one, and I don’t know the answer to that. I may do some research and tests about that. I don’t think there would be a huge difference, but there may be some. For instance, it seems to me that if you have a function that isn’t performed, I don’t think it would be much slower than a template that isn’t loaded. :-)

    Gracias por las ideas interesantes,
    Dave


    Dave Chu · Custom WordPress Developer – likes collaborating with Designers

    #53053

    mmjaeger
    Participant
    Post count: 56

    @braddalton: what’s the pro plus package you mention?

    #53054

    Joan
    Participant
    Post count: 6

    Hola David!

    ¡Su ingles es mejor que mi español! Y supongo que habla catalá.

    Yeah, of course. Spanish and Catalan… and my Spanglish :)

    Thanks for your opinion, I really appreciate it! The more I dig into this, the more I realise there is no correct or wrong answer. I checked several Genesis Gurus, and each one of them has his own ways to get the job done. I guess the performance issues (if there are any of them) are so minimal that it’s just a question of organization and personal preferences.

    I’m guessing that I would rather prefer a clean functions.php… but maybe that’s just because I come from non-Genesis-Ay-que-horror world. ;)

    Thanks for your thoughts!!

    Joan

    #53055

    Joan
    Participant
    Post count: 6
    #53057

    David Chu
    Participant
    Post count: 1315

    Hola Joan!
    Estoy de acuerdo, personal preference is paramount. A balance of templates and functions is good. And even if you use, say, 5 template files, that’s still easier to debug than looking at the crazy amount of template files in Twenty Twelve. ;)

    The Pro Plus package is here. I don’t have it, as most of my work is custom themes, and even though the Genesis framework is my favorite, not all of the Studiopress child themes are to my taste, I’m afraid. (did I say that?)

    It’s good to meet you, I hope to talk with you again!

    Dave
    guitarrista flamenco :-)


    Dave Chu · Custom WordPress Developer – likes collaborating with Designers

    #53058

    Joan
    Participant
    Post count: 6

    And even if you use, say, 5 template files, that’s still easier to debug than looking at the crazy amount of template files in Twenty Twelve.

    lol, absolutely!

    Keep in touch, David!

    #53059

    braddalton
    Participant
    Post count: 8835

    @mmjaeger http://my.studiopress.com/pro-plus/

    This is the smartest investment i have ever made.

    Its also the easiest way to code a new child theme or modify an existing one.

    @Joan I look at how StudioPress do it and they use home.php files.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.