Support » Plugin: BE Subpages Widget » Exclude pages from widget

  • Resolved stueynet

    (@stueynet)


    Would I be able to use a filter to exclude the pages that show in the navigation? The client has a few pages that are “Thank you” pages and are set as subpages for organization purposes. However the thank you pages then show up. I could definitely hack the plugin to do that but it would be preferable to just write a filter.

    Let me know if this is possible! Thanks!

    https://wordpress.org/plugins/be-subpages-widget/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator cubecolour

    (@numeeja)

    Try adding this to your child theme’s functions.php or a custom functions plugin:

    add_filter( 'be_subpages_widget_args', 'be_subpages_exclude' );
    
    function be_subpages_exclude( $args ) {
    $args['exclude'] = '123,234,345';
    return $args;
    }

    Where the numbers in the array are the page IDs of the pages you want to exclude. I’ve not tested this yet but I think it should work.

    I came up with a simpler hack – since I only need to display the top level of subpages I set the pages where I wanted no links displayed as children of a subpage, and hid the nested ul in the css. For example, a ‘thank you’ page might be a child of a ‘checkout’ page, which is in a set of pages under ‘store’.

    .widget_subpages ul ul{display:none;}

    Thread Starter stueynet

    (@stueynet)

    cubecolour that worked perfectly. I even added an ACF option so you can select the pages to exclude globally with the relationship field. Here is the updated code

    add_filter( 'be_subpages_widget_args', 'be_subpages_exclude' );
    
    function be_subpages_exclude( $args ) {
      $excludes = get_field('exclude_from_sub_menu','option');
      $exclude = implode(',', $excludes);
      $args['exclude'] = $exclude;
      return $args;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Exclude pages from widget’ is closed to new replies.