WordPress.org

Support

Support » How-To and Troubleshooting » Unique Single Post Per Category

Unique Single Post Per Category

Viewing 2 replies - 1 through 2 (of 2 total)
  • Yes, this can be achieved by modifying wp_list_categories

    I tried using this code inside my functions.php file

    define(SINGLE_PATH, TEMPLATEPATH . '/single');
    
        add_filter('single_template', 'da_single_template');
    
        function da_single_template($single) {
        global $wp_query, $post;
    
        foreach((array)get_the_category() as $cat) :
    
        if(file_exists(SINGLE_PATH . '/single-cat-' . portfolio . '.php'))
        return SINGLE_PATH . '/single-cat-' . portfolio . '.php';
    
        elseif(file_exists(SINGLE_PATH . '/single-default.php'))
        return SINGLE_PATH . '/single-default.php';
    
        endforeach;
    
       	return $single;
    
    	}

    Apparently the code above is not working. All post shows the portfolio template and not the default. Take note that I have my original single.php in the template folder. Inside the template folder is another “single” folder with the single-cat-portfolio.php and single-default.php.

    anyone care to fix this code?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Unique Single Post Per Category’ is closed to new replies.
Skip to toolbar