I solve in this way.
In the custom template page, that contain the loop of custom post type I add this code:
<?php
/** Template Name: Restrict Area */
get_header();
?>
<?php if ( ! post_password_required() ) { ?>
//content of the page with loop of custom post type
<?php } else{
echo get_the_password_form($post->ID);
} ?>
<?php get_footer(); ?>
In single-custom-post-type.php this code:
<?php get_header(); ?>
<?php
if ( !post_password_required(id_page_custom_template) ) : ?>
//content single
<?php else: ?>
<?php echo get_the_password_form(id_page_custom_template); ?>
<?php endif; ?>
<?php get_footer(); ?>
Where id_page_custom_template must be replaced with the id of the page with custom template.
Related Posts:
- How do I require authorization / login to view a specific set of posts / pages?
- Forcing all posts associated with a custom post type to be private
- How to automatically apply a password to all posts within a custom post type
- How to redirect to a passworded page based on password entered on login screen
- Exclude the_content (); from page password protection
- Giving permission to anyone (non-users as well) with a password to edit a post, possible?
- Get the ID of the latest post
- Do_Shortcode not working for Embed
- How do you get the count of posts in an archive page?
- Custom post type permalink: only use %post_id% and remove %postname%
- List most recent image uploads, but only for specific custom post type
- Fetching private posts or custom post types via WP-API with basic authentication
- Remove admin menu for custom taxonomy attached to custom post type
- How do I list custom taxonomy terms without the links?
- Page not found taxonomy custom post type
- how to filter by last name for custom post
- Order Posts by Taxonomy and Meta Value
- Custom comment status possible?
- Get categories for a specific post – Custom post type
- Group Custom post type in a page by its taxomony tag
- WPMU: Programmatically adding CPT posts to specific blog id
- Getting taxonomy terms used by custom post type
- How do I echo the post type?
- Categories not working as expected with custom post type
- Custom Post Type rewrite rules not working, how to alter the rewrite order?
- error in Advanced Search Form for Custom Post Types in WordPress array_key_exists() expects parameter 2to be array, string given
- Rewrite Custom Post Type URL slug
- Calculating Bayesian average for custom post type
- Merge multiple custom post types in a single archive template
- Problem adding column to WC Subscription [closed]
- Custom Post Type | Fatal Error on register_post_type()
- register_post_type exclude_from_search argument not working
- query posts and custom post type with meta key
- Custom Post Types for Support Ticket plugin?
- How to sort custom post type posts in default order by multiple fields?
- WordPress theme options vs custom post types
- Displaying a form for filtering in custom post type listing
- Query string parameters from custom fields, inconsistent results
- How can I update the permalink everywhere for a custom post type?
- create a template page for a post
- Adding Show Less/More link to Custom Post Meta
- custom admin screen or setting screen for a custom post type [duplicate]
- Get custom taxonomies from multiple posts
- Post image in WordPress not appearing on home page
- Featured image overlay when changing post status
- How to assign permissions for a CPT to a user
- Using POST method in meta box, no results
- Displaying Posts from Custom Post Types
- Custom Post Types strange pagination problem
- Global $post shows null in some of my custom post types archive pages
- 404 in custom post type feed with mistake permalink
- Set featured image to archive.php
- Custom post type editor uses old tinyMCE
- Custom WP_Query doesn’t display all posts
- Custom Type add Transitions
- Pagination not working on custom query on a page
- How to properly delete custom post type posts programmatically
- Query within a foreach within a query (queryception)
- How to implement a different permalink structure for custom post type?
- How do I get_the_postID() for a custom post that uses ACF repeater field?
- CMB2 metabox create select with list of post from CPT
- get_post_permalink() and custom permalink rewriting
- Custom post type name and assigning custom taxonomy
- Custom post type – how to name file?
- custom post creation on front page – on submit a search is done
- Query Custom Posts – Add To Selection
- WordPress custom taxonomy page
- How great custom post type can be?
- How to have multiple search result pages in wordpress with taxonomy terms listed
- count & sum the value of custom field of the author post in dynamic posts
- Set priority to permalinks
- Display a Custom Post Type with Advanced Custom Fields on Homepage
- How to list posts by terms
- Create Post Types from a XML url (Real Estate website)
- How to display all terms from all taxonomies in post, but separately for each taxonomy?
- template id=”1921″ from inside editor doesnt work?
- Wp Query sort order from custom MetaBox
- Pages of my taxonomy terms are showing all posts
- Theme changing issues for Portfolio Custom Post Types
- How do you make a custom post type invisible for subscribers
- Custom Post Types UI paragraph style
- CPT year wise archive based on custom date Field
- Is there a way to re-order the Custom Taxonomy drop-down on a Custom Post listing page?
- How to manage a custom post type archive as a page?
- retrieve custom post image through widget
- predefined custom field on registration page
- multiple custom post type category selection search
- Custom Search Template for Custom Post Types
- Displaying taxonomy icon outside archive page
- Limit number of posts under a post type?
- Cannot modify a registered custom post type rewrite slug
- Why is my custom form saving with ‘autodraft’ as title and slug?
- Sorting custom post types by category?
- Select Menu for Custom post Type does not save
- Tags and Taxonomy links not working for Custom Post Types
- Geolocate Custom Post Type on Save
- Select Category as Page Parent
- Adding custom theme template to custom post type [duplicate]
- Can I have a specific template for products even if they are standard posts and not CPT?
- Taxonomy Archive URL + Template