Support » Plugin: WordPress Carousel - Responsive Image Slider for WordPress » Carousel – Exclude Page and its subpages

  • Hi,
    Great plugin ! I have the Pro version. But I need a little hack :

    *I use…*
    – the Carousel Type : Post, and only for Pages (postType=Page).
    – the normal shortcode [sp_wpcarousel id=”xxx”].

    *The need*
    In the carousel, I need to hide/exclude a precise page, and also ALL its sub- (or children) pages (existing, and future).

    How can I manage that ? Do you have a php code or something else (shortcode attributes) to do that ?

    Thanks a lot for your help,
    Regards,
    Law

    • This topic was modified 1 week, 5 days ago by laucoste.
    • This topic was modified 1 week, 5 days ago by laucoste.
    • This topic was modified 1 week, 5 days ago by laucoste.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    I’ve found something like this… In this example I want to hide children pages from pages 101, 102 and 103.

    But no idea how to make the code perfect, and where to insert it in the plugin (I’m not a developer). Any assistance please ?

     function HideInCarousel($query) {
     if ($query->is_PAGES_TO_HIDE_FROM_CAROUSEL) {
     // exclude children of pages 101,102,103
     $parent = array(101,102,103);
     $children_data = get_pages( array(
     'child_of' => $parent,
     'post_type' => 'page'
     ) );
     $excludes = array($parent);
     foreach( $children_data as $child ) {
     array_push($excludes, $child->ID);
     }
     $query->set('post__not_in', $excludes);
     }
     return $query;
     }
     add_filter('pre_get_posts','HideInCarousel');

    Thank you,
    Regards,
    Law

    Plugin Author ShapedPlugin

    (@shapedplugin)

    Hi,

    You don’t need any PHP code to create WordPress page Carousel excluding some pages(Parent/ Child). You can easily create a carousel with a specific page only. So the pages you want to hide from the carousel don’t select them while creating the carousel. To do that follow the steps:

    1. Select Page from Post Type
    2. Select Specific from Filter Type
    3. Select Pages you want to show in the carousel from Select posts Option. Don’t select the pages you want to hide from the carousel.

    Here is a video demonstration of that: https://screencast-o-matic.com/watch/cYeZjJytTi

    Hope this helps you.

    Thank You

    Hi,

    Thanks for your reply. For the parent pages, it’s OK. But…
    By saying :

    *The need*
    In the carousel, I need to hide/exclude a precise page, and also ALL its sub- (or children) pages (existing, and future).

    I meant that other pages – those that must be displayed in the carousel – have also their own child pages. That includes :
    – Their existing child pages
    – Their child pages to come
    => That is managed manually with your method. But only once the page is published : I would prefer automatically.

    In my configuration, parent pages are all already existing (no new ones will be created), but most of the child pages have to be created.

    The issue is precisely about how to manage the child pages linked to precise parents pages that I will create in the future : Hide them automatically from the carousel.

    Your “inclusive” method is good, but a little thing is missing in order to include also automatically the child pages of the selected parent page : In your video example, child pages ‘Page one’, ‘Page two’ and ‘Page 3’ are not displayed in the carousel.
    Would you see how to do that ?

    Last question, (as my carousel is on the homepage) which filter is the best with performance issue : inclusive or exclusive ? But let’s resolve the above functional question, it will be great !

    Thanks a lot for your assistance, hope it helps other users.
    Law

    Plugin Author ShapedPlugin

    (@shapedplugin)

    Hi @laucoste

    As you’re a pro user of this plugin, please post your last support request in our pro user support forum so that we can help you fast in a better way.

    Note: Discussing the premium plugin here violates WordPress.org forum guidelines.

    Thank you for understanding.
    ShapedPlugin Team

    • This reply was modified 6 days, 10 hours ago by ShapedPlugin.
    • This reply was modified 6 days, 10 hours ago by ShapedPlugin.

    thank you,
    I just created it.
    Please let me know how I can deal with that case…
    Law

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.