• Resolved nggablog

    (@nggablog)


    Please, help me to fix my php code.

    This code purpose to make single template

    <?php
    foreach((get_categories('child_of=1&hide_empty=0')) as $category) {
        $subcat .= "'".$category->cat_ID."',";  // it should produce '1','2','3'
    }
    
    $post = $wp_query->post;
    $c_array=array('$subcat');  // input from above foreach result '1','2','3'
    $show=0;
    foreach ($c_array as $value) {
    if (in_category($value))
    { $show=1; }
    }
    if ($show) {
    include(TEMPLATEPATH . '/single-1.php'); }
    else {
    include(TEMPLATEPATH . '/singledefault.php');
    }
    ?>

The topic ‘Single template: Foreach result into array valiable’ is closed to new replies.