How can i make a simple filter to display only specific pages (include instead of exclude) as an output to wordpress pages widget?

I made this code , but its not working

function specific_pages($output) {

$args = array(
    'include'  => array(147,12,32),
$output = get_posts($args);

return $output;
add_filter('wp_list_pages', 'specific_pages');

the corresponding hook would be https://developer.wordpress.org/reference/hooks/widget_pages_args/

example code:

add_filter( 'widget_pages_args','include_special_pages' );
function include_special_pages( $args ) {
  $args['include'] = array( 147, 12, 32 );
  return $args;
  • Thank you very much for the help. It is working! May 23 '20 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.