How to set up a private custom post type that is accessible in the administrative dashboard?

For the frontend, you can use template_redirect action to identify the page, and perform redirects or adjust the request on the fly (untested): add_action( ‘template_redirect’, static function () { if ( ! is_singular( ‘cpt’ ) && ! is_post_type_archive( ‘cpt’ ) ) { return; } if ( current_user_can( ‘read_private_pages’ ) || current_user_can( ‘read_private_posts’ ) ) { … Read more

Trouble with WordPress Settings API: Form Submits When Fields Called Directly, Fails When Using Callbacks

Thank you for the responses Tom! You got me on track, I should have checked the rendered html earlier. Here’s the answer. The rendered html was showing hidden inputs, for clarity, I’ll just repeat my previous form with the hidden inputs that were being rendered: <form method=”post” action=”<?php echo admin_url(‘admin-post.php’); ?>”> <label>This form wont work</label> … Read more

Display box in sidebar of custom post type

It’s really easy, it’s called meta box and you can create one with the following code. /** * Register meta box(es). */ function plugin_prefix_register_meta_boxes() { add_meta_box( ‘meta-box-id’, __( ‘My Meta Box’, ‘textdomain’ ), ‘plugin_prefix_my_display_callback’, ‘custom_post_type’ ); } add_action( ‘add_meta_boxes’, ‘plugin_prefix_register_meta_boxes’ ); /** * Meta box display callback. * * @param WP_Post $post Current post object. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)