• windofchange87

    (@windofchange87)


    Hello everyone,
    I created a page (page-theater.php), Showing the evidence images of this category

    
    <?php
    /**
     * Template Name: teatro
     *
     *
     * @package WordPress
     * @subpackage riccardodeluca
     * @since Riccardo de Luca 1.0
     */
    
    get_header(); 
    	 $the_query2 = new WP_Query( 'cat=11' );
    ?>
    <div class="container"> 	
        <div class="row">
        <?php 
    	while ( $the_query2->have_posts() ) :
    	$the_query2->the_post();
    	?>
        	<div class="col-sm-6 col-xs-12">
            <div clas="title"><?php the_title('<h1 class="text-center">', '</h1>') ?></div>
    		<?php the_post_thumbnail('full', array('class' => "img-responsive center-block")); ?>
            <div class="text-uppercase text-center"><h4><a href="<?php echo get_permalink( $post->ID ); ?>">read more</a></h4></div>
            <hr style="border:2px solid ">		
            </div>       
        <?php endwhile; 
    	wp_reset_query();
    	wp_reset_postdata()
    	?>
        </div>
     </div>
    <?php get_footer(); ?>
    

    If I click on the link I would like to show me the details of the post

    
    <?php echo get_permalink( $post->ID ); ?>
    

    But the page is empty

    The code page category is:

    
    <?php
    /**
     * The template for displaying Category pages
     *
     * @link https://codex.ww.wp.xz.cn/Template_Hierarchy
     *
     * @package WordPress
     * @subpackage Riccardo De Luca
     * @since Riccardo De Luca 1.0
     */
    get_header(); ?>
    
    <div class="container" style="margin-bottom:30px;">
    	<div class="row">
      
      <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    	<div class=" col-xs-12 col-sm-4">
        	<?php if(has_post_thumbnail()) { ?>
            	<?php the_title('<h1 class="title">','</h1>', true) ?>
                <hr>
    			<?php the_post_thumbnail(array(300), array('class' => "img-responsive") ); ?>
            <?php } ?>
        </div>
        <div class="col-xs-12 col-sm-8 " style="margin-top:20px; min-height:300px;">
        	<?php the_content(); ?>
        </div>
       <hr class="clearfix" style="border:2px solid #333;">
    
      <?php endwhile; endif; 
      	wp_reset_query();
    	wp_reset_postdata()
      
      ?>
    
      </div>
      
    
      </div>
      
    <?php 
    get_footer();
    ?>

    can someone help me? I’m inexperience.
    thank you

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Where are you trying to use echo get_permalink( $post->ID );? Using the variable $post can be a problem in some cases. It depends on where you try to use it. If you are in the standard WP Loop, get_permalink() does not need a parameter, you can just do echo get_permalink();

    In other cases, it may just be that $post has not been declared global. This must be done within any variable scope. It is never assumed or implied. In such cases, I prefer to use get_the_ID(). I like it better than declaring globals. So using your code, try this: echo get_permalink( get_the_ID());

    In some cases, $post could be undefined or have the wrong object assigned. This would generally be outside of WP Loops. You would then need to use alternate means to determine the correct ID. If the request is for a single post or page, the requested post ID can be determined outside of loops with get_queried_object_id()

Viewing 1 replies (of 1 total)

The topic ‘empty page category’ is closed to new replies.