Support » Plugin: List Pages Shortcode » [Plugin: List Pages Shortcode] page order

  • Resolved Zambrano Sergio

    (@sergiozambrano)


    Can you point me where to hack the code to add a class to each li with the page-order?
    (The manual page order defined in the post editor)
    Id like to style the list with different icons, and later exporting those pages to be used on another site, which will definitely make the page-ids different.

    It could be replacing the id attribute if it’s easier to implement, but I prefer to use classes to prevent duplicate icons by omission or duplication of page-order values.

    Thanks.

    http://wordpress.org/extend/plugins/list-pages-shortcode/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Ben Huson

    (@husobj)

    The plugin uses the main WordPress wp_list_pages() function to output the list.

    This function uses a filter which you can use to add classes:
    apply_filters('page_css_class', $css_class, $page)

    Documentation for hooking into filters can be found here.

    Would look something like this:

    function my_page_css_class( $css_class, $page ) {
       $css_class[] = 'my-new-class-' . $page->ID;
       return $css_class;
    }
    add_filter( 'page_css_class', 'my_page_css_class', 10, 2 );

    Ben,

    Thanks, you are the man!

    It sounds like that will add page_order classes to all pages retrieved by wp_list_pages(), but I think there’s no harm 🙂

    Thanks a lot!

    I realized that by using page-slug I would make more sense for linking an icon with its page, rather than keeping track of which one is first or second (a pain if we reorder pages) but $post->post_name returns a number! not the slug.

    If I make global $post inside the function, all of them return the same slug (slug of page id 7: The lowest id)

    Would this be the same as positioning the links in “menu order”. I’m using the plugin “My Page Order” and I need the list to follow that order (not ascending, descending or alpha).

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: List Pages Shortcode] page order’ is closed to new replies.