0

I’m new to scripting, this is a plugin I'd like to modify to output post classes.

When I try using: apply_filters( 'post_class', $page->post_class ) it only outputs array=" ". Do I need an additional function to hook into post classes? In my research I can't tell if my syntax is wrong or I'm missing a function to "pull" in the classes for apply_filters to grab onto. Thanks a ton for any help.

    var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');


    function start_lvl(&$output, $depth = 0, $args = array()) {
        $indent = str_repeat("\t", $depth);
        $output .= "\n$indent<ul class='children'>\n";
    }


    function end_lvl(&$output, $depth = 0, $args = array()) {
        $indent = str_repeat("\t", $depth);
        $output .= "$indent</ul>\n";
    }


    function start_el(&$output, $page, $depth = 0, $args = array(), $id = 0) {
        if ( $depth )
            $indent = str_repeat("\t", $depth);
        else
            $indent = '';

        extract($args, EXTR_SKIP);

        $output .= $indent . '<li id="item_'.$page->ID.'" '.apply_filters( 'post_class', $page->post_class ).'><span>'.apply_filters( 'the_title', $page->post_title, $page->ID ).'</span>';
    }
0

Solved it with generous help using join()...

function start_el(&$output, $page, $depth = 0, $args = array(), $id = 0) {
        if ( $depth )
            $indent = str_repeat("\t", $depth);
        else
            $indent = '';

        extract($args, EXTR_SKIP);

        $output .= $indent . '<li id="item_'.$page->ID.'" class="'.join( " ", get_post_class( "", $page->ID )).'"><span>'.apply_filters( 'the_title', $page->post_title, $page->ID ).'</span>';
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.