home page images by category?

Viewing 15 posts - 1 through 15 (of 18 total)
  • #2558
    bantam
    Participant

    I am working on a new site (http://anitamills.com) using Minimatica and am unclear about a few things: Is there a way to keep some posts from displaying on the home page? I AM able to control what shows up on the other pages, for example the Jewelry page, by having the page only show posts of the Jewelry category. What about the home page? Can only posts with the category “featured” show up on the home page? I find this confusing.

    #2559
    Daniel Tara
    Keymaster

    If you really only want to show only posts from the category “Featured” you can add the argument [code]’category_name’ => ‘Featured'[/code] to [code]query_posts[/code] in loop-slider.php

    #2560
    bantam
    Participant

    That code kept giving me an error and NO images, but I ended up with this, which solves the problem:
    <?php
    if ( is_home() ) {
    query_posts( array ( ‘category_name’ => ‘featured’, ‘posts_per_page’ => -1 ) );
    }?>
    That way the other category pages galleries show their post images, and the home page shows the images we want there.
    Thanks.

    #2561
    bantam
    Participant

    Now I’m wondering why I’m only seeing 4 images. If I hit the arrow, the same four images show – even though I have 8 posts with images set to the ‘featured’ category.

    Now I’m using the code
    <?php
    if ( is_home() ) {
    query_posts( array ( ‘category_name’ => ‘featured’) );
    }?>
    For some reason the query_posts(‘category_name’ => ‘featured’) doesn’t display anything and draws an error in dreamweaver. I seem to need the array() to make it work. Don’t know why. Is that what’s keeping only 4 images showing?

    Thanks. Again, the site is http://anitamills.com

    #2562
    Daniel Tara
    Keymaster

    The limit to 4 images is also set in functions.php by the function [code]minimatica_paged_posts()[/code]. You also need to change the [code]posts_per_page[/code] value there.

    #2563
    bantam
    Participant

    Sorry – it’s not that I want more images to show up at one time – I like the way the four images work and look. It’s that when I click the arrow on the right, the same four images that I just saw are redisplayed. Not sure why. In your demo, it definitely goes on to different images.

    #2564
    bantam
    Participant

    Daniel – Please tell me why on the home page of http://anitamills.com, when I move from page to page with the little white arrows, I keep seeing the same four images. There are at least 8 posts with the “featured” category.

    The code in loop-slider.php is
    <?php
    if ( is_home() ) {
    query_posts( array (‘category_name’ => ‘featured’) );
    }?>

    when I tried just the query_posts(‘category_name’ => ‘featured’);
    the code drew an error. It’s the code you had suggested and the same that I saw in the codex. Somehow adding the “array” made it work. Not sure if that’s why the pages aren’t displaying correctly. Please help!

    #2565
    mymorningstory
    Participant

    I want to clear it up a bit since I think you guys were way more confusing then you need to be!

    There are many people out there like me trying to achieve this! And this is – creating 4 specific images to be on the home page rather then the most recent 4 posts. The easiest way to do this is by creating a category called ‘featured’ and then placing 4 posts under that category. (Most of you might want to erase the left & right images) in the folder or just rename them so they don’t show up.

    Then replace the code:
    <?php query_posts( $args ); ?> ***On line 20***

    with this:
    <?php
    if ( is_home() ) {
    query_posts( array ( ‘category_name’ => ‘featured’, ‘posts_per_page’ => -1 ) );
    }?>

    #2566
    Daniel Tara
    Keymaster

    You need to add the argument [code]’paged’ => get_query_var( ‘paged’ )[/code] to query_posts

    #2567
    clirving
    Participant

    Just to be clear and confirm:

    Go into the loop-slider.php

    Replace:

    <?php query_posts( $args ); ?>

    with:

    <?php
    if ( is_home() ) {
    query_posts( array ( \’category_name\’ => \’featured\’, \’posts_per_page\’ => -1 ) );
    }?>

    and place:

    \’paged\’ => get_query_var( \’paged\’ )

    WHERE?

    When I replaced the first line the menu and slider and other details disappeared. Any feedback is greatly appreciated as I can’t wait to share our fire art images and info with all of Toronto Canada

    #2568
    Jake
    Participant

    Ok guys.
    I really don’t mean to be a bother, but I am an EXTREME beginner when it comes to PHP.
    Could you guys maybe give me an “in more detail” tutorial on how to make this function work. I’d love to set my home page pictures to only draw from one category, but I’ve tried all of the code above and haven’t been able to get it to work.

    PS. Why does it seem that every time I see this bit of code:

    <?php
    if ( is_home() ) {
    query_posts( array ( ‘category_name’ => ‘featured’, ‘posts_per_page’ => -1 ) );
    }?>

    It seems to GAIN more slashes ( / ) ???

    By the end of these posts it looks like this:

    <?php
    if ( is_home() ) {
    query_posts( array ( \\\’category_name\\\’ => \\\’featured\\\’, \\\’posts_per_page\\\’ => -1 ) );
    }?>

    Thanks.

    #2569
    clirving
    Participant

    Here is the code that I have. All is good except I am not sure where to add Daniel’s
    ‘paged’ => get_query_var( ‘paged’ ) to query_posts? Any feedback is fantastic and appreciated.

    <?php
    /**
    * The Loop when viewing in gallery mode
    *
    * @package WordPress
    * @subpackage Minimatica
    * @since Minimatica 1.0
    */
    ?>
    <?php
    global $wp_query, $query_string;
    $paged = get_query_var( ‘paged’ );
    $args = array(
    ‘posts_per_page’ => 4,
    ‘paged’ => $paged,
    ‘ignore_sticky_posts’ => 1
    );
    $args = wp_parse_args( $args, $wp_query->query );
    ?>
    //Commented out this next line of code
    //<?php query_posts( $args ); ?>
    //Added following code from forum – Link: http://www.onedesigns.com/support/topic.php?id=389&page=2
    <?php
    if ( is_home() ) {
    query_posts( array ( ‘category_name’ => ‘featured’, ‘posts_per_page’ => -1 ) );
    }?>
    <?php if( have_posts() ) : ?>
    <div id=”ajax-content”>
    <ul id=”slides” class=”kwicks”>
    <?php while( have_posts() ) : the_post(); ?>
    <?php $thumbnail = null; ?>
    <?php if( has_post_thumbnail() ) : ?>
    <?php $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(), ‘slider-thumb’ ); ?>
    <?php endif; ?>
    <li class=”slide”>
    <div id=”post-<?php the_ID(); ?>” <?php post_class(); ?><?php if( isset( $thumbnail ) ) : ?> style=”background:url(<?php echo $thumbnail[0]; ?>) center no-repeat”<?php endif; ?>>
    <div class=”opacity”></div>
    ” rel=”bookmark”>
    <div class=”entry-container”>
    <h2 class=”entry-title”>” title=”<?php the_title_attribute(); ?>” rel=”bookmark”><?php the_title(); ?></h2>
    <div class=”entry-summary”>
    <?php the_excerpt(); ?>
    <div class=”clear”></div>
    </div><!– .entry-summary –>
    </div><!– .entry-container –>
    </div><!– .post –>

    <?php $thumbnaill = null; ?>
    <?php endwhile; ?>
    <!– #slides –>
    <div class=”clear”></div>
    <?php if ( $wp_query->max_num_pages > 1 ) : ?>
    <div id=”nav-slider”>
    <div class=”nav-previous”><?php next_posts_link( ” ); ?></div>
    <div class=”nav-next”><?php previous_posts_link( ” ); ?></div>
    </div><!– #nav-above –>
    <?php endif; ?>
    <?php rewind_posts(); ?>
    </div><!– #ajax-content –>
    <?php endif; ?>
    <?php wp_reset_query(); ?>

    #2570
    clirving
    Participant

    So here is the code all mashed together by a project manager and artists who does not to php or wordpress and it works! Thanks all:

    //Commented out this next line of code original to minimatica theme
    //<?php query_posts( $args ); ?>
    //Added following code from forum – Link: http://www.onedesigns.com/support/topic.php?id=389&page=2
    <?php
    if ( is_home() ) {
    query_posts( array (
    ‘category_name’ => ‘featured’,
    ‘posts_per_page’ => -1,
    ‘paged’ => $paged ) );
    }?>

    #2571
    clirving
    Participant

    Ignore the added \ as they seem to get inserted in spaces of the code

    #2572
    skittles
    Participant

    Website: http://www.dirtyastronauts.com/store/

    <?php
    if ( is_home() ) {
    query_posts( array ( \\\’category_name\\\’ => \\\’featured\\\’, \\\’posts_per_page\\\’ => -1 \\\’paged\\\’ => get_query_var( \\\’paged\\\’ ) );
    }?>

    returns error

    Parse error: syntax error, unexpected T_STRING, expecting \’)\’ in /home/dirtyast/public_html/store/wp-content/themes/minimatica/loop-slider.php on line 30

    <?php
    if ( is_home() ) {
    query_posts( array (
    \\\’category_name\\\’ => \\\’featured\\\’,
    \\\’posts_per_page\\\’ => -1,
    \\\’paged\\\’ => $paged ) );
    }?>

    Returns error

    Parse error: syntax error, unexpected T_STRING, expecting \’)\’ in /home/dirtyast/public_html/store/wp-content/themes/minimatica/loop-slider.php on line 33

    All i want to do is have the ability to click the category from the front pageand if i click one of the images Categories it takes me to all posts (in my case gallery) as the cattegory.Sorry for leeching some 1 elses post but didnt think it right to start a new topic for the same thing….

Viewing 15 posts - 1 through 15 (of 18 total)

You must be logged in to reply to this topic.