Using pre_get_posts to call postID

Community Forums Forums Design Tips and Tricks Using pre_get_posts to call postID

This topic is: not resolved

This topic contains 4 replies, has 2 voices, and was last updated by  Silver007A 1 year, 1 month ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #51836

    Silver007A
    Participant
    Post count: 3

    Hi,

    I’m using eleven40 theme and have a problem with extra posts appearing on my home page even if I use the featured post plugin, set 7 posts in Setting- Reading and set posts as “sticky” I seem to get my 7 sticky posts plus 3 extras that I don’t want to appear.

    It’s been suggested I use pre_get_posts to call the postID instead of using the sticky option, however, I have to confess I am completely at a loss.

    Would someone be good enough to help me with the code to select the 7 posts that I want to appear on my home page please.

    Thanks for any help,
    :-)

    http://www.virtualglobal.co.uk/
    #51853

    braddalton
    Participant
    Post count: 9415

    You can modify the number of featured posts in the home.php file
    [php]
    remove_action( ‘genesis_loop’, ‘genesis_do_loop’ );
    add_action( ‘genesis_loop’, ‘eleven40_grid_loop_helper’ );
    /** Add support for Genesis Grid Loop */
    function eleven40_grid_loop_helper() {

    if ( function_exists( ‘genesis_grid_loop’ ) ) {
    genesis_grid_loop( array(
    ‘features’ => 1,
    ‘feature_image_size’ => 0,
    ‘feature_image_class’ => ‘alignleft post-image’,
    ‘feature_content_limit’ => 0,
    ‘grid_image_size’ => ‘grid-thumbnail’,
    ‘grid_image_class’ => ‘alignnone’,
    ‘grid_content_limit’ => 250,
    ‘more’ => __( ‘[Continue reading]‘, ‘genesis’ ),
    ) );
    } else {
    genesis_standard_loop();
    }

    }

    genesis();
    [/php]


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #51863

    Silver007A
    Participant
    Post count: 3

    Thanks for the help braddalton, but that didn’t seem to work. It stripped the columns that eleven40 creates on teh home page, the read more and still showed 3 extra posts that aren’t sticky posts.

    If anyone can help i would really appreciate it.

    Thanks,
    :-)

    #51864

    braddalton
    Participant
    Post count: 9415

    You’d need to modify the values in that code so you get 7 features and then make them sticky. You would also need to match your reading settings so only 7 display.

    You can’t display 7 posts as sticky in a grid unless you modify the code. What you can do is display 7 featured posts as sticky but not in a grid.

    Another option is to add styling to your home page posts so they look the same as what they do when they’re sticky.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #52114

    Silver007A
    Participant
    Post count: 3

    Studiopress tech supp have advised me this-

    If you don’t want pagination then I would recommend picking via postID and not using sticky posts. You will have to use the pre_get_posts action to modify the query.

    Here is a tutorial on pre_get_posts

    http://www.billerickson.net/customize-the-wordpress-query/

    However, I don’t understand the tutorial enough to know where to call the postID.

    I don’t know php that well I’m afraid.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.