Changeset 1871212
- Timestamp:
- 05/09/2018 05:22:56 AM (8 years ago)
- Location:
- sitemap-with-woocommerce/trunk
- Files:
-
- 2 edited
-
index.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sitemap-with-woocommerce/trunk/index.php
r1870738 r1871212 60 60 61 61 //Display Pages in Sitemap 62 function sbwpes_sitemap_page( ) { ?>62 function sbwpes_sitemap_page($args = '') { ?> 63 63 <h2><?php _e('Pages', 'easy-sitemap' ); ?>:</h2> 64 64 <ul class="sitemap"> 65 <?php 65 <?php 66 66 //http://codex.wordpress.org/Function_Reference/wp_list_pages 67 wp_list_pages('exclude=&title_li='); //***Exclude page Id, separated by comma. I excluded the sitemap of this blog (page_ID=889). 67 $defaults = array( 68 'depth' => 0, 69 'show_date' => '', 70 'date_format' => get_option( 'date_format' ), 71 'child_of' => 0, 72 'exclude' => '', 73 'title_li' => __( 'Pages' ), 74 'echo' => 1, 75 'authors' => '', 76 'sort_column' => 'menu_order, post_title', 77 'link_before' => '', 78 'link_after' => '', 79 'item_spacing' => 'preserve', 80 'walker' => '', 81 ); 82 83 $r = wp_parse_args( $args, $defaults ); 84 85 if ( ! in_array( $r['item_spacing'], array( 'preserve', 'discard' ), true ) ) { 86 // invalid value, fall back to default. 87 $r['item_spacing'] = $defaults['item_spacing']; 88 } 89 90 $output = ''; 91 $current_page = 0; 92 93 // sanitize, mostly to keep spaces out 94 $r['exclude'] = preg_replace( '/[^0-9,]/', '', $r['exclude'] ); 95 96 // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array) 97 $exclude_array = ( $r['exclude'] ) ? explode( ',', $r['exclude'] ) : array(); 98 99 /** 100 * Filters the array of pages to exclude from the pages list. 101 * 102 * @since 2.1.0 103 * 104 * @param array $exclude_array An array of page IDs to exclude. 105 */ 106 $r['exclude'] = implode( ',', apply_filters( 'wp_list_pages_excludes', $exclude_array ) ); 107 108 // Query pages. 109 $r['hierarchical'] = 0; 110 $pages = get_pages( $r ); 111 112 if ( ! empty( $pages ) ) { 113 if ( $r['title_li'] ) { 114 $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>'; 115 } 116 global $wp_query; 117 if ( is_page() || is_attachment() || $wp_query->is_posts_page ) { 118 $current_page = get_queried_object_id(); 119 } elseif ( is_singular() ) { 120 $queried_object = get_queried_object(); 121 if ( is_post_type_hierarchical( $queried_object->post_type ) ) { 122 $current_page = $queried_object->ID; 123 } 124 } 125 126 $output .= walk_page_tree( $pages, $r['depth'], $current_page, $r ); 127 128 if ( $r['title_li'] ) { 129 $output .= '</ul></li>'; 130 } 131 } 132 133 /** 134 * Filters the HTML output of the pages to list. 135 * 136 * @since 1.5.1 137 * @since 4.4.0 `$pages` added as arguments. 138 * 139 * @see wp_list_pages() 140 * 141 * @param string $output HTML output of the pages list. 142 * @param array $r An array of page-listing arguments. 143 * @param array $pages List of WP_Post objects returned by `get_pages()` 144 */ 145 $html = apply_filters( 'wp_list_pages', $output, $r, $pages ); 146 147 if ( $r['echo'] ) { 148 echo $html; 149 } else { 150 return $html; 151 } 152 //wp_list_pages('exclude=&title_li='); //***Exclude page Id, separated by comma. I excluded the sitemap of this blog (page_ID=889). 68 153 ?> 69 154 </ul> -
sitemap-with-woocommerce/trunk/readme.txt
r1840588 r1871212 13 13 14 14 * [SitemapPost] --- list all posts 15 * [SitemapPage] --- list all pages 15 * [SitemapPage] --- list all pages 16 * [SitemapPage exclude="1493,4071,6,4167,7,8"] --- list exclude pages exambpe 16 17 * [SitemapProduct] --- list all woocommerce products 17 18 * [SitemapCategory] --- list all woocommerce category
Note: See TracChangeset
for help on using the changeset viewer.