• Resolved daybo

    (@daybo)


    Hi,

    I read that I can restrict access to custom post types – but I have no idea how to do that. I can see the extra meta box on the “page” post type, but how can I include that meta box, on a custom post type?

    Thanks
    David

Viewing 8 replies - 1 through 8 (of 8 total)
  • David,

    It should be shown on all custom post types automatically. If it’s not showing, it could be an incompatibility with the plugin that post type comes from.

    Can you tell me a bit more about the post type? What plugin does it come from?

    Thread Starter daybo

    (@daybo)

    Hi Pippin,

    The custom post type is one I have created – it is very simple. The plugin just declares the custom post type and that is it.

    This is the plugin:

    function create_survey() {
    register_post_type( ‘survey’,
    array(
    ‘labels’ => array(
    ‘name’ => ‘Surveys’,
    ‘singular_name’ => ‘Survey’,
    ‘add_new’ => ‘Add New’,
    ‘add_new_item’ => ‘Add New Survey’,
    ‘edit’ => ‘Edit’,
    ‘edit_item’ => ‘Edit Survey’,
    ‘new_item’ => ‘New Survey’,
    ‘view’ => ‘View’,
    ‘view_item’ => ‘View Survey’,
    ‘search_items’ => ‘Search Surveys’,
    ‘not_found’ => ‘No Surveys found’,
    ‘not_found_in_trash’ => ‘No Surveys found in Trash’,
    ‘parent’ => ‘Parent Survey’
    ),

    ‘public’ => false,
    ‘publicly_queriable’ => false,
    ‘show_ui’ => true,
    ‘exclude_from_search’ => true,
    ‘show_in_nav_menus’ => false,
    ‘has_archive’ => false,
    ‘rewrite’ => false,
    ‘menu_position’ => 15,
    ‘supports’ => array( ‘title’, ‘editor’),
    ‘taxonomies’ => array( ” ),
    ‘menu_icon’ => ‘dashicons-clipboard’,
    )
    );
    }

    add_action( ‘init’, ‘create_survey’ );

    Change publicly_queriable to true

    Thread Starter daybo

    (@daybo)

    Hi Pippin,

    Thanks for the suggestion, but sadly that has had no effect. I still cannot see any meta box allowing me to restrict access on the CPT.

    Any other ideas?

    Thanks
    David

    Does the box show up but not save?

    Try it with all other plugins deactivated. Does it work then? If so, reactivate the plugins one by one until the problem comes back.

    Also I believe the argument is spelled publicly_queryabley and not i.

    Thread Starter daybo

    (@daybo)

    I thought you might have had it there with the misspelling, but that wasn’t it. It wasn’t a plugin conflict either…but I did find what it was for anyone else who comes across this. It isn’t 'publicly_queryable'=>true it is actually 'public'=>true. With that set it shows the meta box whether publicly_queryable is true or false.

    Thanks for your help tracking down the problem.

    Regards
    David

    • This reply was modified 8 years, 5 months ago by daybo. Reason: spelling

    Ah! Thanks for sharing!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘restrict custom post type?’ is closed to new replies.