2

I want to make a parallax type link, but I have no idea how to go about it yet. I need to get all post titles with # link and then I can try the parallax thing.

My current category page code bellow. I want to show all post in there..

<div class="content">
    <?php if ( have_posts() ) : ?>

    <h2><?php single_cat_title('',true); ?></h2>


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

           ?>
    <dt><?php the_title(); ?></dt>
    <dd><?php the_content(); ?></dd>
    <?php endwhile; 
            ?>
    <?php else : ?>
    <?php endif; ?>
    </dl>
  </div>

I get all post titles with content nicely. No problem .. but I want to add one div after H2 then want to show

<ul>
<li data-slide="1">title </li>
<li data-slide="2">title </li>
<li data-slide="3">title </li>
<li data-slide="4">title </li>
...
..

</ul>

How could I do that?

Category page will be like bellow

**Category Title**

All Post Title (list)



(under all post )

--------------
Post title
Post Content
---------------

Post title
Post Content
---------------

Post title
Post Content
---------------

Post title
Post Content
---------------

Post title
Post Content
---------------

2 Answers 2

1

Have not tested it but this should get you to your goal. I believe Accore LTD has it correct as well, except your slide #s will be post ID, instead of slide-1, slide-2

<div class="content">
  <?php if ( have_posts() ) : ?>
  <h2><?php single_cat_title('',true); ?></h2>
 <div>
   <ul>
     <?php 
     $inc = 1;
     while ( have_posts() ) : the_post(); ?>
     <li data-slide="<?php echo $inc; ?>"><?php the_title(); ?></li>
     $inc++;
     <?php endwhile; ?>
     <?php else : ?>
     <?php endif; ?>
    </ul>
  </div>

5
  • thanks. actually i want to show title alone then again show one by one title and post. so it mean title will show two time. one time with content and another time on top all just title.just after h2
    – Accore LTD
    Commented Apr 19, 2014 at 3:15
  • If I understand your goal, you want something like this? Title 1 Title 2 Title 1 Content 1 content 1 content1 Title 2 Content 2 content 2 content2
    – jdm2112
    Commented Apr 19, 2014 at 3:18
  • no.. not really...let how i want out out Category title ALL post title ------------------------ Post Title Post Content ------------------------ Post Title Post Content ------------------------ Post Title Post Content
    – Accore LTD
    Commented Apr 19, 2014 at 3:20
  • Having trouble formatting that in comment. Can you add an example with the title two times in your question?
    – jdm2112
    Commented Apr 19, 2014 at 3:20
  • i just update my post .. see how i wanted category page. i already solve it .. bellow i post my code. but now i want to know is there any other nice or easy way to do thanks @jdm2112
    – Accore LTD
    Commented Apr 19, 2014 at 3:24
0

i found one way. and is showing properly. .but i am not sure is that perfect way or not. please give your suggestion

  <ul>  
    <?php
$test = get_the_title();
$args = array( 'cat_name' => $test );
$args = array_merge( $args , $wp_query->query );
get_posts( $args ); while (have_posts()) { the_post(); ?>

<li data-slide="<?php the_ID(); ?>"><?php the_title(); ?></li>

<?php } ?>
 </ul> 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.