• Resolved nevi

    (@nevi)


    Hey There,

    I am a little out of my element here and hoping there is a simple answer to my question. Basically, when we open our FAQ page it is automatically opening the first question. I would prefer that all the questions be collapsed when the page is loaded. Is there a way to do that?

    I found the Template for the FAQ page, but have no idea how to tell this to collapse all of the questions when the page loads.

    get_header();
    $paged= get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
    
     ?>
    
    <div class="content">
    <div class="main_section">
    
    <div class="content_left">
    <?php while ( have_posts() ) : the_post(); ?>
    
    <h1><?php the_title();?></h1>
    <?php the_content();?>
    	<?php endwhile; // end of the loop. ?>
        <?php
    	 $questions_query = $wp_questions_query;
    	 $wp_questions_query = null;
    	 $wp_questions_query = new WP_Query( array ( 'showposts' => '10', 'paged' => $paged, 'post_type' => 'questions', 'orderby' => 'menu_order', 'order' => 'ASC') );
    ?> <?php if($wp_questions_query->have_posts()) : $faqindex = 0; ?>
    <?php
    				   while ($wp_questions_query->have_posts()) : $wp_questions_query->the_post();
    				   $imageArray = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full');
    	               $imageURL = $imageArray[0];
    				   $faqindex++;
    				  if($faqindex== 1)
    				  {
    					  $cls = 'block';
    					  $img = 'minus_pic.jpg';
    				  }
    				  else
    				  {
    					  $cls = 'none';
    					   $img = 'plus_pic.jpg';
    				  }
    				   ?>
    
    <div class="blog_headingpart">
    <h4 class="font14 green" style="padding-bottom:0px;"><span class="black">Q<?php echo $faqindex;?>)</span><?php the_title();?></h4>
    <div id="detail_id<?php echo $faqindex;?>" style="display:<?php echo $cls;?>; padding-top:8px;">
    <div class="faq_uqestionpart">
    <?php the_content();?>
    </div>
    </div>
    <div class="right" onclick="toggleDiv('detail_id<?php echo $faqindex;?>','conrtol_id<?php echo $faqindex;?>')"><a href="javascript:void(0)"><img src="<?php echo get_template_directory_uri(); ?>/images/<?php echo $img;?>" alt="" id="conrtol_id<?php echo $faqindex;?>" /></a></div>
    <div class="clear"></div>
    </div>
    
     <?php endwhile; ?>	
    
    			  <?php if(function_exists('wp_pagenavi')) { ?>
    		    <?php wp_pagenavi( array( 'query' => $wp_questions_query ) ); ?>
    			<?php } ?>
    
    			<?php else : ?>
    
    	       <?php echo "No Records Found"; ?>
    
    <?php  endif; ?>
    <?php
    	$wp_questions_query = null;
    	$wp_questions_query = $questions_query;
    	wp_reset_postdata();
     ?>         
    
    <div class="clear"></div>
    
    </div>
    <?php get_sidebar();?>
    
    <div class="clear"></div>
    
    </div>
    </div>

    Thanks in advance – the assistance is really appreciated!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi there,

    I took a quick peek and made a change.

    Try this:

    get_header();
    $paged= get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
    
     ?>
    
    <div class="content">
    <div class="main_section">
    
    <div class="content_left">
    <?php while ( have_posts() ) : the_post(); ?>
    
    <h1><?php the_title();?></h1>
    <?php the_content();?>
    	<?php endwhile; // end of the loop. ?>
        <?php
    	 $questions_query = $wp_questions_query;
    	 $wp_questions_query = null;
    	 $wp_questions_query = new WP_Query( array ( 'showposts' => '10', 'paged' => $paged, 'post_type' => 'questions', 'orderby' => 'menu_order', 'order' => 'ASC') );
    ?> <?php if($wp_questions_query->have_posts()) : $faqindex = 0; ?>
    <?php
    				   while ($wp_questions_query->have_posts()) : $wp_questions_query->the_post();
    				   $imageArray = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full');
    	               $imageURL = $imageArray[0];
    				   $faqindex++;
                                       /*Change was here by: Brad Nelson*/
    				   $cls = 'none';
    			           $img = 'plus_pic.jpg';
                                       /*End of change*/
    				   ?>
    
    <div class="blog_headingpart">
    <h4 class="font14 green" style="padding-bottom:0px;"><span class="black">Q<?php echo $faqindex;?>)</span><?php the_title();?></h4>
    <div id="detail_id<?php echo $faqindex;?>" style="display:<?php echo $cls;?>; padding-top:8px;">
    <div class="faq_uqestionpart">
    <?php the_content();?>
    </div>
    </div>
    <div class="right" onclick="toggleDiv('detail_id<?php echo $faqindex;?>','conrtol_id<?php echo $faqindex;?>')"><a href="javascript:void(0)"><img src="<?php echo get_template_directory_uri(); ?>/images/<?php echo $img;?>" alt="" id="conrtol_id<?php echo $faqindex;?>" /></a></div>
    <div class="clear"></div>
    </div>
    
     <?php endwhile; ?>	
    
    			  <?php if(function_exists('wp_pagenavi')) { ?>
    		    <?php wp_pagenavi( array( 'query' => $wp_questions_query ) ); ?>
    			<?php } ?>
    
    			<?php else : ?>
    
    	       <?php echo "No Records Found"; ?>
    
    <?php  endif; ?>
    <?php
    	$wp_questions_query = null;
    	$wp_questions_query = $questions_query;
    	wp_reset_postdata();
     ?>         
    
    <div class="clear"></div>
    
    </div>
    <?php get_sidebar();?>
    
    <div class="clear"></div>
    
    </div>
    </div>

    Let me know if this works!

    Thread Starter nevi

    (@nevi)

    That did the trick – thanx a million!! I really appreciate it!!

    Glad to be of help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Help With The FAQ Page’ is closed to new replies.