Created
April 19, 2018 07:46
-
-
Save Inzman/e6dd62c3e9dfa6668afeb1128a48f9ea to your computer and use it in GitHub Desktop.
If page slug contains a number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if(is_user_logged_in()){ | |
| $args = array( | |
| 'sort_order' => 'asc', | |
| 'sort_column' => 'post_title', | |
| 'post_type' => 'page', | |
| 'numberposts' => -1, | |
| 'post_status' => 'publish', | |
| 'suppress_filters' => false | |
| ); | |
| $pages = get_posts($args); | |
| echo '<table>'; | |
| foreach($pages as $page){ //pre($page); | |
| $slug = $page->post_name; | |
| $warning = (1 === preg_match('~[0-9]~', $slug)) ? 'style="background:red;"': ''; | |
| echo '<tr '.$warning.'><td style="padding:10px;">'.$page->post_title.'</td><td style="padding:10px;">'.$slug.'</td></tr>'; | |
| } | |
| echo '</table>'; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment