Add new template page

hi, i need to insert some php code for some functions in a reserved area. i thought about inserting them in a custom template, but i can’t see it in the template section of the pages. i compiled the newtemplate.php file in the template section of pro “public_html/wp-content/themes/pro/framework/views/custom” and added the header by copying it from another template but it doesn’t work

<?php
//Template Name: Area Riservata
get_header();
?>
  <div class="x-container max width offset">
    <div class="x-main full" role="main">

      <?php while ( have_posts() ) : the_post(); ?>

        <?php x_get_view( 'global', '_content', 'the-content' ); ?>

      <?php endwhile; ?>

    </div>
  </div>

<?php get_footer(); ?>

<?php

//se l'utente è loggato mostra messaggio di benvenuto e post
	if ( is_user_logged_in() ) {?>

		<?php //info dell'utente loggato
			  global $current_user; 
			  get_currentuserinfo(); 
			  $my_user = $current_user->user_login ; 
			  $my_user_level = $current_user->user_level ;
			  $my_user_id = $current_user->ID;
			  echo 'Benvenuto, '. $my_user; 
	    ?>
		<hr />

		<?php //se l'utente è l'admin mostro tutti i contenuti, altrimenti mostro quelli dell'utente associato al post
			  if($my_user_level == 10) {
			
				  //loop con tutti i contenuti
				  $wpquery = new WP_Query(array(
				        'post_type'	=> 'area-riservata',
				  ));
				
			  } else {

			      //loop con i contenuti del relativo utente + quelli contrassegnati come all
				  $wpquery = new WP_Query(array(
						'post_type'	=> 'area-riservata',
						'meta_query' => array(
							'relation' => 'OR',
								 array(
						            'key' => 'users',
						            'value' => $my_user_id,
						            'compare' => '='
						         ),
										
						         array(
						            'key' => 'users',
						            'value' => 'all',
						            'compare' => '='
						         )
							 )
						)
					);

			  }
		?>
		<?php if ( $wpquery -> have_posts() ) : while ( $wpquery -> have_posts() ) : $wpquery -> the_post(); ?>
		
			<?php //richiamo le info dell'utente associato al post
				  $user_selected = get_post_meta($post->ID, 'users', TRUE);
				  $user_info = get_userdata($user_selected); 	   
			?>
				  
		    <div class="post">
			    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
			    
			    <?php the_content('Leggi...');?>
			    
			    <?php if($user_selected == 'all') { ?>
			    
			    	<small><i><?php  echo 'Contenuto per Tutti'; ?></i></small>
			    
			    <?php } else  { ?>
			    
			    	<small><i><?php  echo 'Contenuto per l\'utente: ' . $user_info->user_login . "\n";	 ?></i></small>
			    
			    <?php } ?>
			</div>
			<hr />
			 			 			 	
		<?php endwhile; else: ?>
			<div class="post">
				<h3>Spicenti, non ci sono contenuti...</h3>
		    </div>
		<?php endif; ?>
		
		<a href="<?php echo wp_logout_url( home_url() ); ?>" title="Logout">Logout</a>	
	<?php } else { ?>

		Area Riservata

			<h2>Login</h2>
			
			<?php wp_login_form(); ?>

	<?php } ?>

</div>
<?php get_footer(); ?>

Hello @ICT73,

Thank you for the inquiry.

The template definition is invalid. Please check this documentation for more info on how to create global page templates.

https://developer.wordpress.org/themes/template-files-section/page-template-files/#creating-custom-page-templates-for-global-use

We also recommend adding this new template in your child theme. If you haven’t activated a child theme, please check the documentation below.

https://theme.co/docs/child-themes

If you’re interested, you can check out our One service. Let us know if you need more info.

Best regards.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.