Skip to content

Instantly share code, notes, and snippets.

@Inzman
Created April 19, 2018 07:46
Show Gist options
  • Select an option

  • Save Inzman/e6dd62c3e9dfa6668afeb1128a48f9ea to your computer and use it in GitHub Desktop.

Select an option

Save Inzman/e6dd62c3e9dfa6668afeb1128a48f9ea to your computer and use it in GitHub Desktop.
If page slug contains a number
<?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