WordPress.org

Ready to get started?Download WordPress

Forums

List Pages Shortcode
[resolved] page order (5 posts)

  1. Zambrano Sergio
    Member
    Posted 2 years ago #

    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/

  2. Ben Huson
    Member
    Plugin Author

    Posted 2 years ago #

    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 );
  3. Zambrano Sergio
    Member
    Posted 2 years ago #

    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!

  4. Zambrano Sergio
    Member
    Posted 2 years ago #

    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)

  5. laptophobo
    Member
    Posted 2 years ago #

    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).

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic