Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter corfred

    (@corfred)

    Oh golly!

    global $haspaintings, $hasphotography, $hasobjects;

    That did the trick! Thank you so so so much!

    Thread Starter corfred

    (@corfred)

    Ha I will forgive you I guess.

    500 Error is gone! But, no sidebar is being displayed.

    From sidebar.php

    <div id="secondary" class="widget-area" role="complementary">
    				<?php
    				if (is_archive()) {
    				 	 if ($haspaintings) {
    					 	dynamic_sidebar( 'paintings-sidebar' );
    					 }
    					 if ($hasphotography) {
    						dynamic_sidebar( 'photography-sidebar' );
    					 }
    					 if ($hasobjects) {
    					 	dynamic_sidebar( 'objects-sidebar' );
    					 }
    				 } else {
    					dynamic_sidebar( 'sidebar-1' );
    				 }
    				 ?>
    		</div><!-- #secondary -->

    Thread Starter corfred

    (@corfred)

    Still getting the error

    PHP Parse error: syntax error, unexpected ‘=’ in /wp-content/themes/twentytwelve/archive.php on line 26

    That is the line -> $has-paintings = false;

    Thread Starter corfred

    (@corfred)

    So would this be right? or am I declaring the flags in the wrong place … because I am getting a server error everywhere that I attempt to place them on this page.

    By the way, I really appreciate your help.

    <section id="primary" class="site-content">
    		<div id="content" role="main">
    
    			<?php
    			$has-paintings = false;
    			$has-photographs = false;
    			$has-objects = false;
    			/* Start the Loop */
    			if ( have_posts() ) : while ( have_posts() ) : the_post();
    
    				 if (in_category( 'paintings' )) {
    				    $has-paintings = true;
    				  }
    				  if (in_category( 'photography' )) {
    				    $has-photographs = true;
    				  }
    				  if (in_category( 'objects' )) {
    				    $has-objects = true;
    				  } 
    
    				get_template_part( 'content', get_post_format() );
    
    			endwhile;
    
    			?>
    
    		<?php else : ?>
    			<?php get_template_part( 'content', 'none' ); ?>
    		<?php endif; ?>
    
    		</div><!-- #content -->
    	</section><!-- #primary -->
    Thread Starter corfred

    (@corfred)

    Thanks for the response!
    I do have that closing curly bracket.
    And I was afraid that was going to be the solution as it is a bit above my knowledge level.
    It makes sense that it looks at the current post.

    I have been trying to find a way for it to scan all of the posts on that page and count if the any of those three categories has a count > 0, and if TRUE, add that sidebar.

    Does it sound like I am on the right track with that?

Viewing 5 replies - 1 through 5 (of 5 total)