WordPress.org

Ready to get started?Download WordPress

Forums

WP StrapThirteen
[resolved] Have the slider display pages rather than posts (7 posts)

  1. Pumpkinwaffle
    Member
    Posted 10 months ago #

    Hi!

    First of all I'd like to thank you guys for making such a great theme, it literally took hours before I could find something that wouldn't make my eyes bleed ^^

    I would like for the slider on the homepage to display some selected pages rather than posts (as my highlighted content is already featured on pages). Would that be possible, or is it already possible and I missed something?

    If you want to have a better idea feel free to take a look at my website, as you can see the main content (games and tutorials) are already on their own page for easy access. But it would be so sweet to have them on that slider too.

    http://pumpkinwaffle.net

    I'm pretty new to PHP and CSS but I'm familiar with coding so I should be able to understand technical answers.

    Thanks in advance.

    Oh and also can the slider background image be just transparent? when I upload a plain transparent image it is set to white..

  2. Zulfikar Nore
    Member
    Theme Author

    Posted 10 months ago #

    Hello Pumpkinwaffle,

    Thank you for the appreciation and glad you like the theme :)

    As for the slider - if I understand you correctly, you want to have selected pages as slides instead of posts right?

    If that is correct then you'd either have to enter certain page IDs in a text field or simply let the slider run through the latest set number of pages - what's your preference? Or both options?

    Let me have your feedback and I'm sure I can come up with something ready to use out of the box or something you can improve upon and extend :)

    Regards,
    Zulf.

    BTW going to mark this as "Not a support question" but will continue communicating on it till I get you some kind of a result.

  3. Pumpkinwaffle
    Member
    Posted 10 months ago #

    Thank you for your kind reply.

    Entering certain page IDs would definitely be the way to go for me, if you don't mind explaining to me how to achieve this I'd be delighted.

    Also, what size (pixel) would you recommend to be used in the slider?

    Thank you

  4. Zulfikar Nore
    Member
    Theme Author

    Posted 10 months ago #

    OK here goes - first of all please make a backup copy of slider.php or better still, change the name of the theme to something like pumpkinwaffle :) i.e rename the theme folder (a copy) and in style.css change WP StrapThirteen to PumpkinWaffle.

    Then edit slider.php and replace the following

    <?php $strapthirteen_query = new WP_Query(array(
         'category_name'  => get_theme_mod( 'strapthirteen_slide_cat' ),
         'posts_per_page' => get_theme_mod( 'strapthirteen_slide_number' )
    )); ?>
    
    <?php while ($strapthirteen_query->have_posts()) : $strapthirteen_query->the_post(); ?>

    With this:

    <?php $strapthirteen_page_slider_query = new WP_Query(array(
         'post_type' => 'page',
         'post__in' => array( 2, 5, 12, 14, 20 )),
         'posts_per_page' => get_theme_mod( 'strapthirteen_slide_number' )
    )); ?>
    
    <?php while ($strapthirteen_page_slider_query->have_posts()) : $strapthirteen_page_slider_query->the_post(); ?>

    In its current state this code requires manual insertion of the page IDs - I'm still working on a way to populate these via the theme Customizer and when I've figured it out I'll update the theme to facilitate the use of either posts or pages via a check box selection.

    As for the image size - since the parent theme has the sizes set between 1600 and 3200 then I'd recommend going with this width for best results. Height can be adjusted in the carousel.css as desired.

    Hope that helps to get your started but if there's anything else I can help with please feel free to give me a shout :)

    Zulf

  5. Pumpkinwaffle
    Member
    Posted 10 months ago #

    It works! Thank you so much for the help, one little thing, on the line

    'post__in' => array( 2, 5, 12, 14, 20 )),

    You closed your parenthesis twice which returned an error you may want to edit your post in case someone else was to use this snippet.

    However I only have the "About" page in the slider and I have no clue on how to manually set the pages I want featured on the slider, if you could give me one last little push it'd be great.

    I'll play around with the sizes to see what works best for me, thank you for the indication on the size.

    You're really doing an amazing job with your themes and the support you give, I'll make sure to recommend your themes to anyone in need.

    Maxime

  6. Zulfikar Nore
    Member
    Theme Author

    Posted 10 months ago #

    You closed your parenthesis twice which returned an error you may want to edit your post in case someone else was to use this snippet.

    They are closed twice because its a continuation of the WP_Query which has double arrays - but I'll revisit the code to double check and fix it if need.

    The page ids given in the snippet are just an example - to find the ids for your own pages go to Admin > > Pages and on the list hover over the Page Name - at this point if you look at the bottom left of your browser you'll see a url which looks something like http://domainname.com/wp-admin/post.php?post=13&action < < the number here is the page id that you need.

    An finally, thank you for the kind words and your gesture of recommendation is very much appreciated :)

  7. Zulfikar Nore
    Member
    Theme Author

    Posted 10 months ago #

    Actually you are right (I was ending the firs array before I should - just rechecked and here's the correct code:

    <?php $strapthirteen_page_slider_query = new WP_Query(array(
         'post_type' => 'page',
         'post__in' => array( 2, 5, 12, 14, 20 ),
         'posts_per_page' => get_theme_mod( 'strapthirteen_slide_number' )
    )); ?>
    
    <?php while ($strapthirteen_page_slider_query->have_posts()) : $strapthirteen_page_slider_query->the_post(); ?>

Reply

You must log in to post.

About this Theme

About this Topic