Advertisement
mbis

Exclude IDs

Jan 16th, 2019 (edited)
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. function pm_excluded_ids() {
  2.     return array(426, 512, 604);
  3. }
  4.  
  5. function pm_ignore_post_ids($uris) {
  6.     $excluded_ids = (array) pm_excluded_ids();
  7.  
  8.     if(!empty($uris) && is_array($uris)) {
  9.         $uris = array_diff_key($uris, array_flip($excluded_ids));
  10.     }
  11.  
  12.     return $uris;
  13. }
  14. add_filter('permalink_manager_uris', 'pm_ignore_post_ids');
  15.  
  16. function pm_hide_uri_editor($bool) {
  17.     global $post;
  18.  
  19.     $excluded_ids = (array) pm_excluded_ids();
  20.  
  21.     if(!empty($post->ID) && in_array($post->ID, $excluded_ids)) {
  22.         return false;
  23.     }
  24.  
  25.     return $bool;
  26. }
  27. add_filter('permalink_manager_hide_uri_editor_post_page', 'pm_hide_uri_editor');
  28. add_filter('permalink_manager_show_uri_editor_post_post', 'pm_hide_uri_editor');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement