• Hello,

    I have created a custom meta box than shows on all pages. However, I only want the meta box to show on pages that have children. Parent pages.

    Any ideas?

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • Phil

    (@owendevelopment)

    Where you generated the meta box code (functions file or plugin), maybe try placing it inside (not tested this myself):

    function is_tree( $pid ) {
        if ( is_page() ) {
            return ( get_the_ID() == $pid || in_array( $pid, get_post_ancestors( get_the_ID() ) ) );
        }
      return false;
    }

    More info on get_post_ancestors… here.

    Thread Starter obidos

    (@obidos)

    Hi Phil and thank you for your reply.

    I am adding my custom meta within my functions file and here is the bit of code I have to add it to the pages:-

    function add_custom_meta()
    {
    	add_meta_box("subpages", "Include page in sub navigation", "get_pages_list", "page", "normal", "default");
    }
    add_action('add_meta_boxes', 'add_custom_meta');

    So it shows on all pages. I just need it on the top level parent pages.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom meta box on specific pages’ is closed to new replies.