• I’ve spent some time researching the best way to do this and I’m coming up empty.

    Here is a link to the development site:

    http://creativeconundrum.com/mdsc/

    Problem Statement:
    Client would like to have posts within the Audio/Video Resources to display on hover.

    Here is the code that I added to the theme’s functions.php. The SQL part of it has been tested in phpMyAdmin and it pulls exactly the data I’m looking for:

    <?php
        function mdsc_avposts() {
    	global $wpdb, $post_link;
    	$sort_code = 'ORDER BY name ASC, post_date DESC';
    	$the_output = '';
    
        $mdsc_post_list = (array)$wpdb->get_results("
            SELECT DISTINCT ID, post_title, post_date, post_name
            FROM wp_posts, wp_term_relationships, wp_term_taxonomy
            WHERE wp_posts.ID = wp_term_relationships.object_id
            AND wp_term_relationships.term_taxonomy_id = '13'
            AND wp_term_taxonomy.taxonomy = 'category'
            AND wp_posts.post_status = 'publish'
            AND wp_posts.post_type = 'post'	");
    
    	if ( empty($mdsc_post_list) )
    		return NULL;
    
    	$mdsc_post_list = array_values($mdsc_post_list);
    
    	$the_output .= '<ul>';
    	foreach ($mdsc_post_list as $post_link) {
            $class = 'post-item post-item-' . $mdsc_post_list->ID;
            $current_post = get_the_ID();
            if ( isset($current_post) && $current_post && is_singular() && ($mdsc_post_list->ID == $current_post) )
                $class .=  ' current-post';
                $the_output .= '<li class="' . $class . '"><a class="" href="' . get_permalink($mdsc_post_list->ID) . '">' . apply_filters('the_title', $mdsc_post_list->post_title) . '</a></li>';
    		$the_output .= '</li>';
    	}
    	$the_output .= '</ul>';
    	echo $post_link;
    }
    ?>

    The updated functions.php did not make the theme break. 🙂

    Can anyone who might be reading this give me a clue or advice on how to make the posts display under the Audio/Video Resources category link?

Viewing 1 replies (of 1 total)
  • Hi Marj,

    Not sure I understand what it is you need. Have the required posts been given the appropriate category in the WP Admin?

    I know it might seem like a stupid question, but if the posts are already categorized as ‘Audio/Video Resources’ or whatever then you just need to call get_posts() using the categoryID or name as the paramter.

    Having things display when hovered over is a css or javascript function and has nothing to do with the php / worpress functionality!

    A clearer description of just exactly what it is that you need might help.

Viewing 1 replies (of 1 total)
  • The topic ‘posts in category from horizontal navigation’ is closed to new replies.