Skip to content

Instantly share code, notes, and snippets.

@benfurfie
Created October 2, 2019 08:25
Show Gist options
  • Save benfurfie/d5d47496040e3eed25ef4ad193390b13 to your computer and use it in GitHub Desktop.
Save benfurfie/d5d47496040e3eed25ef4ad193390b13 to your computer and use it in GitHub Desktop.
WordPress Cheatsheet

WordPress Cheatsheet

CPTs

Hiding entries from view

Sometimes you want to have a CPT, but not have single post entries for each item, such as a slider, which queries entries to build up an array of items.

In this case, the trick is to set the CPT's value for publicly_queryable to false.

E.g.

function awards_custom_post_type()
{
    $args = array(
        'labels' => array(
            'name' => __('Awards'),
            'singular_name' => __('Award')
        ),
        'public' => true,
        'publicly_queryable' => false
    );

    register_post_type('award', $args);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment