Ready to get started?Download WordPress


[resolved] Looping back to first post in category (4 posts)

  1. themil
    Posted 4 years ago #

    Hey everyone,

    I have this code:

    $current =  get_permalink();
    $prevPost = get_previous_post(true);
    $prevURL = get_permalink($prevPost->ID);
    $nextPost = get_next_post(true);
    $nextURL = get_permalink($nextPost->ID);
    <map name="Map" id="Map">
    <area shape="circle" coords="142,43,40" href="<?php echo get_settings('home'); ?>" /> <!-- Home button -->
    <area shape="circle" coords="343,43,37" href="../restaurants/" /> <!-- Back to category button -->
    <area shape="circle" coords="829,43,39" href="<?php echo $nextURL ?>" /> <!-- Back button -->
    <area shape="circle" coords="1147,43,39" href="<?php echo $prevURL ?>" /> <!-- Next button -->

    It works 100%.
    But what I need help with is I want it to loop back to the first/last post in the category it's listing rather than just when it gets to the final post, just refreshing that post over and over?
    Or is there a way to pick up that it is the last and first post post so I can change the image and remove the MAP link?

    Thanks in advanced!


  2. MichaelH
    Posted 4 years ago #

  3. themil
    Posted 4 years ago #


    Cheers Michael :)

  4. themil
    Posted 4 years ago #

    Bah! It woorks... but Doesn't work!
    I will endeavor this more.

    I have made so many different variations but this works, but displays the next post, but only the next post for both!

    <img src="<?php bloginfo('template_url'); ?>/explorer_client/<?php $category = get_the_category(); echo $category[0]->cat_name;?>-category-top-bar.png" alt="" width="1280" height="90" border="0" usemap="#Map" />
    <map name='Map' id='Map'>
      <area shape="circle" coords="142,43,40" href="<?php echo get_settings('home'); ?>" />
      <area shape="circle" coords="343,43,37" href="../<?php $category = get_the_category(); $category = $category[0]; echo $category->category_nicename;?>" />
      <area shape="circle" coords="829,43,39" <?php previous_post_link_plus('menu_order', 'loop'); ?> />
      <area shape="circle" coords="1147,43,39" <?php next_post_link_plus('menu_order', 'loop'); ?> />

    Oh, and I did edit the plugin .PHP file to incorporate the shortening :)
    Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic