• Resolved carl-johan

    (@carl-johan)


    Hey.

    I’m doing a theme for a client and have an idea on how I want the “News” page to work, but not a clue on how to code it.
    The theme is a very basic one, with just two columns, basically one displaying a vertical menu (left column) and one the content (right column).

    For the “News” page, I would like to display the content of 3 posts in the right column, no problem there.
    But I would also like to have a list of the corresponding post titles in the left column, which is not a problem either, except the titles should not be linked to the single post.
    I want the link to go to the top of that post entry, still on the “News” page, just like an anchor tag would work.

    Could anyone give me some input on how to make that happen?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter carl-johan

    (@carl-johan)

    Solved it myself. If anyone is interested, heres how I did it (haven’t tried it cross-browser yet, but I think it’s valid)

    I put this in my sidebar (Menu):

    <?php
    $rand_posts = get_posts('numberposts=3&orderby=ASC');
     foreach( $rand_posts as $post ) :
    ?>
    <li>*<a href="<?php echo get_option('home'); ?>#<?php the_title(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>

    And this in my content:

    <?php $the_query = new WP_Query('showposts=3&orderby=post_date&order=desc');
    
    while ($the_query->have_posts()) : $the_query->the_post();
    $do_not_duplicate = $post->ID; ?>
    
    <a name="<?php the_title(); ?>" id="<?php the_title(); ?>">
    <div class="entry">
    <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_content('Read the rest of this entry &raquo;'); ?></a>
    
    <strong><?php the_title(); ?></a></strong><?php the_time('Ymt') ?>
    
    <?php the_excerpt('Read the rest of this entry &raquo;'); ?>
    </div>
    </a>
    <?php endwhile; ?>

    Works like a charm.

    That was brilliant! Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘A list of anchors to the top of each post?’ is closed to new replies.