ThemeShaper Forums » ThemeShaper WordPress Themes

[closed]

Beginners function reference

(11 posts)
  • Started 4 years ago by mogito2000
  • Latest reply from ridgely
  • This topic is not a support question
  1. mogito2000
    Member

    I have just adopted the Thematic framework and can already see how powerful it is ( 2 solid days of playing around has helped ).

    However, searching for the most commonly used and useful functions can be time consuming.

    I'm starting my own functions reference file and was thinking that it might be something that could be used by the thematic community ( especially beginners )

    So, if you are interested, i ask you kindly to start adding some of the most commonly used and useful bits of code that can be used in your child themes functions.php ( with explanation if possible )

    We can then add these to a reference document and make it available for everyone to download....

    NOTE* Please flag up any code that does not work.

    Cheers.

    Posted 4 years ago #
  2. mogito2000
    Member

    REMOVE SIDEBAR FROM CERTAIN PAGE

    // filter thematic_sidebar() .. no display for the page 'Forum', keep it for the rest
    function remove_sidebar() {
     // We test if we are on the page 'Forum'
     if (is_page('forum')) {
     // Yes, we are .. now we switch off the sidebar
     return FALSE;
     } else {
     // we are not .. we leave the switch on
     return TRUE;
     }
    }
    // Connect the filter to thematic_sidebar()
    add_filter('thematic_sidebar', 'remove_sidebar');
    Posted 4 years ago #
  3. This is a really great idea, thanks!
    New contact methods:

    //New Profile Contact Methods
    function my_new_contactmethods( $contactmethods ) {
    // Add Twitter
    $contactmethods['twitter'] = 'Twitter';
    //add Facebook
    $contactmethods['facebook'] = 'Facebook';
    
    return $contactmethods;
    }
    add_filter('user_contactmethods','my_new_contactmethods',10,1);

    remove the sidebar from a group of pages:

    // filter thematic_sidebar() .. no display for the page 'page1','page2','page3','page4', keep it for the rest
    function remove_sidebar() {
     // We test if we are on the page 'page1','page2','page3','page4'
     if (is_page(array('page1','page2','page3','page4'))) {
     // Yes, we are .. now we switch off the sidebar
     return FALSE;
     } else {
     // we are not .. we leave the switch on
     return TRUE;
     }
    }
    // Connect the filter to thematic_sidebar()
    add_filter('thematic_sidebar', 'remove_sidebar');

    Favicon:

    //Favicon
    function childtheme_favicon() { ?>
        <link rel="shortcut icon" href="<?php echo bloginfo('stylesheet_directory') ?>/images/favicon.ico"/>
    <?php }
    
    add_action('wp_head', 'childtheme_favicon');

    these are just a few of mine as I'm still very new to the functions but I'll be keeping an eye on this thread for more...

    Posted 4 years ago #
  4. Robo
    Member

    Mogito2000, this is exactly what I have started myself. I think thematic needs a section devoted just to these functions -- a library of them... :-)

    Posted 4 years ago #
  5. there was some talk about this a while ago. i have answered the same question multiple times.... partly b/c people don't use the search and partly b/c the search doesn't provide good access to the tons of absolute gems hidden on here. so i think it is a brilliant and much needed idea. anyone have a thought as to the best WAY/place to keep this organized/structured? one large thread will eventually lose it's effectiveness (in terms of things being easy to find).

    Posted 4 years ago #
  6. A search-able index of functions would really help this community more than any other resource, imo.

    Look's like Ian's customization guide was going the way of a wiki, but from what I can tell, it's been left on the wayside.

    We should discuss creating a publicly accessible wiki, like at wiki.com or some other freely available resource so that we can cut-n-paste till we're blue in the face.

    I'd volunteer to help test/moderate entries for something like this.

    Posted 4 years ago #
  7. Robo
    Member

    Adding footer text function...
    
    function my_footer($thm_footertext) {
    	$thm_footertext =  '© 2010 blar blar blar by <a href="http://www.blar.com">blar blar blar</a>';
    return $thm_footertext;
    }
    add_filter('thematic_footertext', 'my_footer');
    Posted 4 years ago #
  8. Robo
    Member

    Add Google analytics below the footer code...

    function analytic_footer() {?>
    	<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
    	<script type="text/javascript">_uacct = "UA-GOOGLE NUMBER HERE";urchinTracker();</script>
    <? }
    add_filter('thematic_after', 'analytic_footer');
    Posted 4 years ago #
  9. Robo
    Member

    Hey there xxxevilgrinxxx, I don't understand what your first piece of code does, or how it works...?

    // Add Twitter
    $contactmethods['twitter'] = 'Twitter';

    Care to explain? Thanks!

    Posted 4 years ago #
  10. It adds new fields to your user profile - people go to your profile and will see a field for twitter and facebook as well as the standard ones

    Posted 4 years ago #
  11. @Tarpontech - I second the wiki idea. I'd be happy to help wherever I can. Question being how, and where do we set this up?

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.