• It would be nice to add these options to the “siblings” shortcode :

    * Include current post (as label)
    * Sort pages (i.e. I’d like to sort by menu order)

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter yanick.rochon

    (@yanickrochon)

    Here’s a basic support implementation :

    pulic static function siblings( $atts = null, $content = null ) {
      $atts = shortcode_atts( array(
          'depth' => 1,
          'class' => '',
          'include_current' => 0,
          'sort' => ''
        ), $atts, 'siblings' );
      global $post;
      $return = wp_list_pages( array( 'title_li' => '',
          'echo' => 0,
          'child_of' => $post->post_parent,
          'depth' => $atts['depth'],
          'exclude' => (int) $atts['include_current'] ? '' : $post->ID,
          'sort_column' => $atts['sort']
        ) );
      return ( $return ) ? '<ul class="su-siblings' . su_ecssc( $atts ) . '">' . $return . '</ul>' : false;
    }

    Shortcode

    [su_siblings depth="0" include_current="1" sort="menu_order"]

    If you want to include the parent page before the siblings, here’s a quick fix:

    in the function: public static function siblings (around line 921)

    replace:

    return ( $return ) ? '<ul class="su-siblings' . su_ecssc( $atts ) . '">' . $return . '</ul>' : false;

    with:

    return ( $return ) ? '<ul class="su-siblings' . su_ecssc( $atts ) . '"><li><a>post_parent ) . '">' . get_the_title( $post->post_parent ) . '</a></li>' . $return . '</ul>' : false;

    If anyone has a better way feel free to correct me.

    • This reply was modified 8 years, 2 months ago by nextorontoweb.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shortcode improvement : sibblings’ is closed to new replies.