ThemeShaper Forums » Thematic

[closed]

functions.php ignored

(11 posts)
  • Started 5 years ago by kinkythought
  • Latest reply from ScottNix
  • This topic is not resolved
  1. I've never written php before so I'm trying to sort my way through with copying and pasting. I'm adding code to my functions.php to remove the metadata except the date from posts and to add a favicon, but none of the changes that I make are being reflected. I'm sure that I'm just doing something wrong, but I can't figure out what it might be. This is my functions.php:

    <?php
    
    //
    //  Custom Child Theme Functions
    //
    //Remove Post Metadata except Post Date
    
    function date_only() {
    		global $id, $post, $authordata;
        $postmeta = '<div class="entry-meta">';
        $postmeta .= '<span class="entry-date"><abbr class="published" title="';
        $postmeta .= get_the_time(thematic_time_title()) . '">';
        $postmeta .= get_the_time(thematic_time_display());
        $postmeta .= '</abbr></span>';
        $postmeta .= "</div><!-- .entry-meta -->\n";
    		return $postmeta;
    }
    
    add_filter('thematic_postheader_postmeta', 'date_only');
    
    function childtheme_favicon() { ?>
        <link rel="shortcut icon" href="<?php echo bloginfo('stylesheet_directory') ?>/images/favicon.ico">
    <?php }
    
    add_action('wp_head', 'childtheme_favicon');
    ?>

    what dumb thing am I doing wrong?

    Posted 5 years ago #
  2. Jamie Mitchell
    Member

    Hi mate...

    i tested this code out below and it works to filter the meta stuff like you want, but i couldn't work out the favicon either, only just started php myself.

    <?php
    
    //
    //  Custom Child Theme Functions
    //
    //Remove Post Metadata except Post Date
    
    function date_only() {
    		global $id, $post, $authordata;
        $postmeta = '<div class="entry-meta">';
        $postmeta .= '<span class="entry-date"><abbr class="published" title="';
        $postmeta .= get_the_time(thematic_time_title()) . '">';
        $postmeta .= get_the_time(thematic_time_display());
        $postmeta .= '</abbr></span>';
        $postmeta .= "</div><!-- .entry-meta -->\n";
    		return $postmeta;
    }
    
    ?>
    <?php
    add_filter('thematic_postheader_postmeta', 'date_only');
    ?>

    J

    Posted 5 years ago #
  3. hmm.. yeah, there must be something else going on that's just keeping functions.php from being recognized at all. I haven't a clue what it could be, though.

    Posted 5 years ago #
  4. Jamie Mitchell
    Member

    Hi mate...

    did you try out the code i pasted in above, what happened exactly.

    also are you using a childtheme?

    ...J

    Posted 5 years ago #
  5. yes, I'm using a child theme and the styles.css is working fine. I used the included base child theme to work off. I copy-pasted the code you posted exactly, but the metadata still shows below my posts.

    Posted 5 years ago #
  6. Jamie Mitchell
    Member

    you pasted the code above in the child theme functions.php ?

    also check you have the child them activated in your wordpress admin, not the thematic theme.

    ...J

    Posted 5 years ago #
  7. Yep, the child theme is activated, I posted that code exactly into the child functions.php, still no dice. I'm going to keep plugging away and figure out what's wrong, because obviously I've fudged something up along the way.

    Posted 5 years ago #
  8. Zip your child theme's directory and mail it to chris (at) wupperpiraten (dot) de

    Will check it for you ..

    Cheers,

    Chris

    Posted 5 years ago #
  9. steve.c
    Member

    Hi

    I had the same problem. I was reading http://themeshaper.com/2009/05/03/filters-wordpress-child-themes/ and trying to get the hooks to work, but no matter what I added to functions.php, nothing happened.

    After searching around the forums for a bit, someone mentioned something about this fucntion: function childtheme_override_brandingopen(){}

    When I added that to my functions.php, then it worked - it was no longer ignored.

    Can anyone explain why? Am I missing something, or using an outdated method of doing things?

    Thanks

    Posted 3 years ago #
  10. @Steve C. I had the same experience. I'm trying to get a 3-column layout to appear for my home page per this article:

    http://programming.thematic4you.com/2010/01/how-to-use-a-different-layout-for-a-certain-page/

    Nothing was happening, so then I started testing my style.css file in the child theme and sure enough itw as not being recognized. I added your snippet from above and now it appears the child main style.css is being recognized, but the functions.php is not, here's what I have in there:

    //
    //  Custom Child Theme Functions
    //
    // Hack - added by me to get child theme recognized
    function childtheme_override_brandingopen(){}
    
    // I've included a "commented out" sample function below that'll add a home link to your menu
    // More ideas can be found on "A Guide To Customizing The Thematic Theme Framework"
    // http://themeshaper.com/thematic-for-wordpress/guide-customizing-thematic-theme-framework/
    
    // Adds a home link to your menu
    // http://codex.wordpress.org/Template_Tags/wp_page_menu
    function childtheme_menu_args($args) {
        $args = array(
            'show_home' => 'Home',
            'sort_column' => 'menu_order',
            'menu_class' => 'menu',
            'echo' => true
        );
    	return $args;
    }
    //add_filter('wp_page_menu_args','childtheme_menu_args');
    
    // Unleash the power of Thematic's dynamic classes
    //
    // define('THEMATIC_COMPATIBLE_BODY_CLASS', true);
    // define('THEMATIC_COMPATIBLE_POST_CLASS', true);
    
    // Unleash the power of Thematic's comment form
    //
    // define('THEMATIC_COMPATIBLE_COMMENT_FORM', true);
    
    // Unleash the power of Thematic's feed link functions
    //
    // define('THEMATIC_COMPATIBLE_FEEDLINKS', true);
    
    // filter thematic_create_stylesheet to implement your own stylesheets
    // This is to apply a 3-Column layout for the homepage
    function my_stylesheet($content) {
        // We test if we're on home or on your frontpage
      if (is_home() || is_front_page()) {
        // yes, we are .. now let's load the 3c-fixed layout
            $content = "\t";
            $content .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
            $content .= get_bloginfo('stylesheet_directory') . "/style-home.css";
            $content .= "\" />";
            $content .= "\n\n";
      } else {
        // we are not .. let's load the 2c-r-fixed layout
            $content = "\t";
            $content .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
            $content .= get_bloginfo('stylesheet_directory') . "/style.css";
            $content .= "\" />";
            $content .= "\n\n";
        }
            // $content will be handed back to thematic_create_stylesheet
        return $content;
    }
    // connect the filter to thematic_create_stylesheet
    add_filter ('thematic_create_stylesheet', 'my_stylesheet');

    Just wondering if anything appears out of place? Any assistance is appreciated.

    Posted 3 years ago #
  11. Alright, something fishy is going on here.

    So I had a clean Thematic (latest dev realease) and decided to see if I could figure this issue out since it should be cake.

    After setting it up per the article above, my style-home.css was not reading the import section below.

    @import url('../thematic/library/styles/3c-fixed.css');

    But.. it was reading the other styles, even import ones except the 3c-fixed.css.

    What I did was copy the actual CSS from the 3c-fixed.css and pasted it replacing the import in style-home.css. It then worked fine.

    The whole branding (hack or whatever) broke some divs and didn't do anything for me, so it sounds like my issue was completely different from yours.

    I know this won't help because I couldn't correctly duplicate the issue, but anyone else out there might find it beneficial that you do have an actual problem (and not some lame spelling mistake, etc). The current demo of what I produced is (temporarily) up at scottnix.com/test4

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.