samedi 8 août 2015

php function run based on category

I am trying to get functions (a) and (b) to fire when the proper $description is run but so far I haven't been able to figure it out. Its probably something really simple.

Server is locked into php 5.2

    add_filter( 'category_description', 'so_31889614_category_description', 10, 2 );
    function so_31889614_category_description ( $description, $category ) 
    {
//testing with var_dump shows [int(7)] [int(2)] and [int(3)] in the proper places on the pages
            var_dump( $category );
            if ( $category->term_id == 2 || $category->term_id == 3 ) {
                $description = a();
            } elseif ( $category->term_id == 7 ) {
                $description = b();
            } else {
            $description;
        }
        return $description;
    }

function a($content) {
//stuff
return $content;
}
function b($content) {
//stuff
return $content;
}

Thank you for any help.

Aucun commentaire:

Enregistrer un commentaire