treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Wordpress/Thematic] Putting Dynamic classes BACK

  • Hello All, I like to develop on the wordpress thematic theme framework. I recently implemented the "Adding Sub-Titles To Menu Links" technique from http://themeshaper.com/wordpress-menu-tricks/ Its works great except it strips the navigational list items of their dynamic classes. Here is the code provided:


    // Adds descriptive text to link titles
    // With help from http://blog.clearskys.net/2008/12/17/how-to-adding-menu-sub-titles-to-a-theme/
    function sub_page_list() {
    global $wpdb;
    $sql = \"SELECT p.ID, p.post_title, p.guid, pm.meta_value FROM \" . $wpdb->posts . \" AS p LEFT JOIN \";
    $sql .= \"(SELECT post_id, meta_value FROM \" . $wpdb->postmeta . \" AS ipm WHERE meta_key = 'subtitle') \";
    $sql .= \"AS pm ON p.ID = pm.post_id \";
    $sql .= \"WHERE p.post_type = 'page' AND p.post_parent = 0 AND p.post_status = 'publish' \";
    $sql .= \"ORDER BY p.menu_order ASC \";
    $sql .= \"LIMIT 0, 10\";
    $rows = $wpdb->get_results($sql,OBJECT);
    if($rows) {
    foreach($rows as $row) {
    echo \"<li>\";
    $link_url = get_permalink($row->ID);
    echo \"<a href=\\"$link_url\\"\" . \"\\">$row->post_title</a>\";
    echo \"<span style=\\"display:block;\\">$row->meta_value</span>\";
    echo \"</li>\";
    }
    }
    }

    // Filter the menu to add the list
    function childtheme_page_menu() { ?>
    <div class=\"menu\">
    <ul>
    <?php if (is_front_page()) { ?>
    <li><a href=\"<?php bloginfo('home') ?>/\" title=\"<?php echo wp_specialchars( get_bloginfo('name'), 1 ) ?>\" rel=\"home\">
    Home <span style=\"display:block;\">This is the home page</span>
    </a></li>
    <?php } else { ?>
    <li><a href=\"<?php bloginfo('home') ?>/\" title=\"<?php echo wp_specialchars( get_bloginfo('name'), 1 ) ?>\" rel=\"home\">
    Home <span style=\"display:block;\">Return to the home page</span>
    </a></li>
    <?php } ?>

    <?php sub_page_list(); ?>

    </ul>
    </div>
    <?php }
    add_filter('wp_page_menu','childtheme_page_menu');


    I thought I could get it to work by changing the opening li tag like this, but it just didnt work. Can someone point out what I'm doing wrong?


    if($rows) {
    foreach($rows as $row) {
    echo \"<li class=\"/post-<?php the_ID(); ?>/\">\";
    $link_url = get_permalink($row->ID);
    echo \"<a href=\\"$link_url\\"\" . \"\\">$row->post_title</a>\";
    echo \"<span style=\\"display:block;\\">$row->meta_value</span>\";
    echo \"</li>\";
    }
    }
    }
  • Any idea's anyone?
  • Hey man,

    I read through the link you sent, and it sounds like you're creating a custom function to create these item, and that function doesn't have the Dynamic classes? I would compare the custom function you are using with the function that has the dynamic classes, and fine where it's coming from...

    Sorry I couldn't me of more help, but this sounds like a question for the guy who programmed it.