WordPress.org

Ready to get started?Download WordPress

Forums

Hardcoding Categories not working in my theme (1 post)

  1. ahuggup86
    Member
    Posted 2 years ago #

    i am trying to hard code some categories in an loop but there not showing correct categories..

    this is the code before change

    <?php
     	$cc = 0; $c = 10; while ($cc < $c) {
    	$cc++;
    	unset($cat, $catlink, $loop);
     	$category = 'featured_category_' . $cc;
    	if (option::get($category)) {
       		$cat = get_category(option::get($category),false);
      		$catlink = get_category_link(option::get($category));
     	$posts_num = option::get('featured_categories_posts');
    	$loop = new WP_Query( array( 'post__not_in' => get_option( 'sticky_posts' ), 'posts_per_page' => $posts_num, 'orderby' => 'date', 'order' => 'DESC', 'cat' => option::get($category) ) );
    	?>

    and this is the code i changed to test if it would work

    <?php
     	$cc = 0; $c = 10; while ($cc < $c) {
    	$cc++;
    	unset($cat, $catlink, $loop);
     	$category = 'featured_category_' . $cc;
    	if (option::get($category)) {
       		$cat = get_category(option::get($category),false);
      		$catlink = get_category_link(option::get($category));
     	$posts_num = option::get('featured_categories_posts');
    	$loop = new WP_Query( ( 'cat=36,37,38' ) ); ?>
    	<div class="featured_cat">
    		<h3><a>"><?php echo"$cat->name";?></a> <span></span></h3>

    [no bumping]

Topic Closed

This topic has been closed to new replies.

About this Topic