Only want one category in carousel

Discussion in 'Forum Rules' started by chelsea15, Oct 12, 2014.

  1. chelsea15

    chelsea15 New Member

    Joined:
    Oct 12, 2014
    Messages:
    11
    Likes Received:
    0
    I was attempting to restrict my carousel to only one category in the Infoway theme. I went to frontpage.php and entered the category pets into this code: <p> <?php the category('pets '); ?></p> Now the homepage won't display. I tried to delete it and return to the original code but still the page does not display:
    <p> <?php the category(', '); ?></p> Can you help me to show only one category and see below where I may have mistakenly changed the code so it does not display? My website is still in production mode.


    <!--carousel slider -->

    <?php
    query_posts('post_type=post');
    while (have_posts()) : the_post(); ?>
    <?php
    $content1 = $post->post_content;
    $searchimages1 = '~<img [^>]* />~';
    preg_match_all( $searchimages1, $content1, $pics1 );
    $iNumberOfPics1 = count($pics1[0]);
    $car_img = 'off';
    if ($iNumberOfPics1 > 0){
    $car_img = 'on';
    break;
    } else {
    $car_img = 'off';
    }
    endwhile;
    wp_reset_query();
    ?>
    <?php if ((have_posts()) && post_type_exists( 'post') && (($car_img == 'on') || (has_post_thumbnail()))){ ?>
    <div id="carousel-full">
    <div class="carousel-posts">
    <ul>
    <?php
    $args = array(
    'post_status' => 'publish',
    'posts_per_page' => -1,
    'order' => 'DESC'
    );
    $query = new WP_Query($args);
    ?>
    <?php while ($query->have_posts()) : $query->the_post(); ?>
    <?php
    $content = $post->post_content;
    $searchimages = '~<img [^>]* />~';
    /*Run preg_match_all to grab all the images and save the results in $pics*/
    preg_match_all( $searchimages, $content, $pics );
    // Check to see if we have at least 1 image
    $iNumberOfPics = count($pics[0]);
    if (($iNumberOfPics > 0) || (has_post_thumbnail())){
    ?>
    <li>
    <div class="thumbnail">
    <?php if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail())) { ?>
    <?php inkthemes_get_thumbnail(200, 140); ?>
    <?php } else { ?>
    <?php inkthemes_get_image(200, 140); ?>
    <?php
    }
    ?>
    <span></span>
    </div>
    <div class="wrap">
    <h6> <a href="<?php the_permalink() ?>" rel="bookmark" title="infoway Images"><?php the_title(); ?></a> </h6>
    <p> <?php the category(', '); ?>
    </p>
    </div>
    </li>
    <?php
    }
    endwhile;
    // Reset Query
    wp_reset_query();
    ?>
    </ul>
    </div>
    <div class="carousel-nav"> <a class="prev" href="#"><span>prev</span></a> <a class="next" href="#"><span>next</span></a> </div>
    </div>
    <?php
    }
    ?>
    <!-- /End Carousel -->
     
  2. Pramod

    Pramod Guest

    Joined:
    Aug 8, 2014
    Messages:
    2,847
    Likes Received:
    63
    Hello,
    In the carousel you cannot show any particular category post. Download a fresh copy of theme and install theme to make this visible.
    Thanks & Regards
    Pramod
     
  3. chelsea15

    chelsea15 New Member

    Joined:
    Oct 12, 2014
    Messages:
    11
    Likes Received:
    0
    The homepage is now displaying.

    I just need to show one blog category and all the posts within the category and exclude the other categories. I searched further and see someone asked this question but I need more info. to make it work. Here is the previous question and answer:

    I would like to exclude a specific blog category from the carousel, as i don't want to use images in some blog posts. However if I try to do this then the carousel will stop showing. Is there any way to exclude a category (or even specify a category) for the carousel to use, so we can avoid the 'carousel not showing' issue.

    Answer:

    Go to front-page.php present in your theme directory and add the code given below
    Code:
    'category_name'=>'Enter Your Category Name Here'
    I tried to do that but nothing happened. I am not that familiar with php. Do I put the code in the carousel section? Can it go anywhere in the section? Is there any special code that needs to precede or end the above line? I am assuming if I put my category name in there, then the other categories will not show?
    if I do this, does it mean that the Current News section will only show the one category also?

    Thank you for your help.
     
  4. Pramod

    Pramod Guest

    Joined:
    Aug 8, 2014
    Messages:
    2,847
    Likes Received:
    63
    Hello,
    Sorry,Unfortunately there in not a way to do this.
    Thanks & Regards
    Pramod
     

Share This Page