WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] archives, search, categories aren't displaying posts properly (11 posts)

  1. annie hearts
    Member
    Posted 8 months ago #

    Hi,

    I've been trying to fix two problems in my twenty eleven theme. The problems appear on the search, archives and categories pages in this way:

    1) the thumbnails are so big that they go right across into my sidebar, bumping my sidebar down to the bottom of the page

    2) only 3 post excerpts are displayed (I'd like 10 to show)

    Here's my website:
    http://www.anniehearts.com

    Any help is appreciated!
    Thanks,
    Annie

  2. alchymyth
    The Sweeper & Moderator
    Posted 8 months ago #

    1)
    you seem to have some broken code in content.php in your chidl theme; please post the full code (use the pastebin as outlined in http://codex.wordpress.org/Forum_Welcome#Posting_Code )

    there is also no css code to resize the images to a max width; once you have corrected the errors in the code, try to add to style.css in the child theme:

    .hentry .attachment-post-thumbnail {
    max-width: 97.5%; /* Fluid images for post excerpts */
    }

    2)
    '3' might what you have set under dashboard - settings - reading; blog pages show at most...

    to set a different number of posts per page for the home page and archives, review:
    http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts#Changing_the_number_of_posts_per_page.2C_by_post_type

  3. annie hearts
    Member
    Posted 8 months ago #

    Thanks for your response alchymyth!

    I have pasted my child theme in a paste bin.

    Once you have a look I will input the code you gave me above.

    I very much appreciate your help!
    Annie

  4. alchymyth
    The Sweeper & Moderator
    Posted 8 months ago #

    can you post the code of content.php of your child theme?

  5. annie hearts
    Member
    Posted 8 months ago #

    Sure. Here you go.

    Thank you!

  6. annie hearts
    Member
    Posted 8 months ago #

    I also tried putting the code below into my style.css of my child theme and my archives are still showing 3 posts.

    I tried the code from the codex link you sent verbatim but it didn't work, so I changed it a bit and it still doesn't work.

    function hwl_home_pagesize( $query ) {
        if ( is_admin() || ! $query->is_main_query() )
            return;
    
        if ( is_home() ) {
            // Display only 3 post for the original blog archive
            $query->set( 'posts_per_page', 1 );
            return;
        }
    
        if ( is_post_type_archive ) {
            $query->set( 'posts_per_page', 20 );
            return;
        }
    }
    add_action( 'pre_get_posts', 'hwl_home_pagesize', 3 );

    Any suggestions? Thanks again!

  7. alchymyth
    The Sweeper & Moderator
    Posted 8 months ago #

    please try and insert the missing opening div:

    <div class="entry-summary">

    directly before these lines:

    <?php the_excerpt(); ?>
    </div><!-- .entry-summary -->

    that should hopefully remove some of the existing errors, and enable the newly to be added styles to be effective.

  8. annie hearts
    Member
    Posted 8 months ago #

    Hurray alchymyth!! It worked!!

    I also added your other code above and now my images fit beautifully.
    Ahh. So much better!

    I will try to codex code to see if I can get my 10 posts showing.

    Thank you!!!

  9. annie hearts
    Member
    Posted 8 months ago #

    Alas, the codex code did not work...
    :(

    I'm sorry to ask for help again, but might you have any suggestions on how to have 3 posts on my main blog page and 10 posts on the archives, categories and search pages???

    I truly appreciate your help!

  10. alchymyth
    The Sweeper & Moderator
    Posted 8 months ago #

    try to set the number of posts per page to 10 within dashboard - settings - reading;

    then add this to functions.php in the child theme:

    function hwl_home_pagesize( $query ) {
        if ( is_admin() || ! $query->is_main_query() )
            return;
    
        if ( is_home() ) {
            // Display only 3 post for the original blog index
            $query->set( 'posts_per_page', 3 );
            return;
        }
    
    }
    add_action( 'pre_get_posts', 'hwl_home_pagesize', 1 );
  11. annie hearts
    Member
    Posted 8 months ago #

    The almighty alchymyth has done it again!

    The problem is fixed and the website looks perfect.

    THANK YOU!

    Annie

Reply

You must log in to post.

About this Topic