View Single Post
Old 12-06-2007, 12:44 PM   #8 (permalink)
d4v1d
The Contributor
Good Samaritan 
 
d4v1d's Avatar
 
Join Date: Dec 2007
Location: Durban, South Africa
Posts: 51
Thanks: 1
d4v1d is on a distinguished road
Default

You're trying to pass a variable through to your function, but your function is not set up to receive any information. By including the variable within the function declaration like i showed above, you're assigning any input to that variable, which will be a valid variable now within the function with the value you assigned to it from outside the function.

So you would now take out your constant, thus your code would look like this:

PHP Code:
function posts_by_category($number) {



    global 
$wpdb$post;



    
$tp $wpdb->prefix;



    
$pc_header get_option('pc_header');



    
$sort_code 'ORDER BY name ASC, post_date DESC';

    
$the_output NULL;





    
$last_posts = (array)$wpdb->get_results("

        SELECT 
{$tp}terms.name, {$tp}terms.term_id

        FROM 
{$tp}terms, {$tp}term_taxonomy

        WHERE 
{$tp}terms.term_id = {$number}

                AND 
{$tp}term_taxonomy.taxonomy = 'category'

        
{$hide_check} 

    "
);



    if (empty(
$last_posts)) {

        return 
NULL;

    }



    
$the_output .= stripslashes($ddle_header); 



    
$used_cats = array();;

    
$i 0;

    foreach (
$last_posts as $posts) {

        if (
in_array($posts->name$used_cats)) {

            unset(
$last_posts[$i]);

        } else {

            
$used_cats[] = $posts->name;

        }

        
$i++;

    }

    
$last_posts array_values($last_posts);



    foreach (
$last_posts as $posts) {

$the_output .='<div class="col">';

      
$the_output .= '<h2>' apply_filters('list_cats'$posts->name$posts) . '</h2>';



          
$where apply_filters('getarchives_where'"WHERE post_type = 'post' AND post_status = 'publish'" $r );

    

 
$arcresults $wpdb->get_results("SELECT *, COUNT( `ID` ) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' AND ID IN (Select object_id FROM {$tp}term_relationships, {$tp}terms WHERE {$tp}term_relationships.term_taxonomy_id ={$number}) GROUP BY 1 ORDER BY post_date DESC LIMIT 0 , 5;");
          
        
//. $posts->term_id .

            
$the_output .= '<ul class="latestmenu">';

      foreach ( 
$arcresults as $arcresult ) {

           
$the_output .= '<li><a href="' get_permalink($arcresult->ID) . '">' apply_filters('the_title'$arcresult->post_title) . '</a></li>';

       }

    

          
$the_output .= '';

       }

       
$the_output .= '</ul></div>';

       return 
$the_output;

}

function 
pc_generate($content) {

    
$content str_replace("<!-- postsbycategory -->"posts_by_category(), $content);

    return 
$content;


and you would call this function as follows:

PHP Code:
posts_by_category(4
d4v1d is offline  
Reply With Quote