WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Using : Without functions.php - would my theme work ? (11 posts)

  1. sandeep4688
    Member
    Posted 4 years ago #

    Hi, want to know: without function.php - would my theme work !!!

    I have been comfortable in understanding and making all the files ..like index.php, single.php, archive.php, archives.php, search.php, style.css, sidebar.php, footer.php --- but I'm stuck on Function.php . I'm not enough expert to write down my own functions. What to do ??

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    what functions do you need?

  3. You don't have to use functions.php in a theme. I didn't for years :) If you leave it blank, or out of your theme, you just won't have custom functions.

  4. sandeep4688
    Member
    Posted 4 years ago #

    Thanks @Ipstenu, Is this (Ipstenu.org) working without functions.php ?

    @RVoodoo : Just wanted to know, If don't use function.php ...then what may be the pros and cons.

  5. No, ipstenu.org (and all my other sites) have some customization in functions.php.

    Here are some nice write ups of what it's good for:
    http://www.mattvarone.com/wordpress/functionsphp-wordpress-themes/
    http://www.pearsonified.com/2008/05/how-to-use-wordpress-functions.php
    http://www.binarymoon.co.uk/2007/05/wordpress-tips-and-tricks-functionsphp/

    My mentality is this:

    1) Never hard code into your theme what a plugin can do
    2) Never do in a plugin what can be done in one line in functions.php
    3) Never do in functions what can be done in .htaccess
    4) Never hack core! EVER!

    An example of what's in my functions.php:

    /* Remove curly quotes, which annoy me */
    remove_filter('comment_text', 'wptexturize');
    remove_filter('the_content', 'wptexturize');
    remove_filter('the_excerpt', 'wptexturize');
    remove_filter('the_title', 'wptexturize');
    
    /* No Frakin' Self Pings
    */
    function no_self_ping( &$links ) {
            $home = get_option( 'home' );
            foreach ( $links as $l => $link )
                    if ( 0 === strpos( $link, $home ) )
                            unset($links[$l]);
    }
  6. Mark / t31os
    Moderator
    Posted 4 years ago #

    2) Never do in a plugin what can be done in one line in functions.php

    Agree totally apart from the above line, sometimes there are functions and features that could be in a plugin but are better suited in the theme, because they are specific to usage of the given theme.

    Additionally i do most of my code testing in the theme's functions file, i personally find it easier and quicker to use and debug.... amongst other reasons .... it can always be moved into a plugin later.

    All the same, non-coders should ignore what i've said and stick to the advice given... ;)

  7. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    @sandeep4688
    should you find the need to add options later through a functions.php file.....you don't need to be expert enough to make one! I have many functions in my functions.php that I have just borrowed from around the web/forum. Just a matter of cutting and pasting!

  8. sandeep4688
    Member
    Posted 4 years ago #

    @Ipstenu
    Your Links are quite helpful! And now, find bit easy to make and integrate functions, in functions.php :). Thanks a lot !

  9. @t31os_ That's why the 'One Line' is important there :) I have very little in my functions.php for ipstenu.org (my other site is way more complicated and has a fugly functions).

    The credo came from this line actually:
    remove_filter('the_title', 'wptexturize');

    Someone pointed me to a weighty plugin to do the same thing, and someone else gave me that line. I was ecstatic and decided that if ONE line in a functions.php file could do it, provided I comment it correctly, I'm not using a plugin that mighht ave other conflict issues down the line.

    If I have something that's complicated or needs lots of options or frequent tweaks, even IF it's small code, it ends up a plugin. But that was my reaction to overkill :)

    @sandeep4688, good luck with functions :) They're fantastically useful.

  10. sandeep4688
    Member
    Posted 4 years ago #

    @Ipstenu, infact you made my way easy; if you've more links on functions :) ... I'd love to go through them also.

  11. Google has a lot of examples :)

    I also downloaded a LOT of themes and studied them to get an idea what I wanted to duplicate.

Topic Closed

This topic has been closed to new replies.

About this Topic