WordPress.org

Ready to get started?Download WordPress

Forums

Archive prev / next year (7 posts)

  1. Meez
    Member
    Posted 2 years ago #

    Hi,

    it's about this page:
    http://www.humanconcern.nl/category/media/hc-media/

    On the right you see an Archive menu. How do i make 'Prev' / and 'Next' links so i can see more years. For example another row of 5 years if you click on 'Prev':

    2007
    2006
    2005
    2004
    2003

    And so on...

    Here is the code for the archive menu:

    [code moderated - the forum limit for posting code is 10 lines - for more use the pastebin]

    Thanks alot!

  2. Meez
    Member
    Posted 2 years ago #

    So here is the code in 10 lines:

    <?php
    				$year = isset($_POST['year']) ? $_POST['year'] : '';
    				for ($i=0; $i<5; $i++)
    				{
    					$time = strtotime("-".$i." year", time());
    					$date = date("Y", $time);
    					$sel = $date == $year  ? ' articleYearsSelected ' : '';
    					$url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
    					$url= 'http://www.humanconcern.nl/';
    					?>
    					<tr>
    						<td class="articleCell"><img src="/wp-content/themes/humenconcern/images/arrow.png" /></td>
    						<td class="articleYears articleCell<?php echo $sel;?>">
    						<a href="<?php echo $url;?><?php echo $date;?>"><?php echo $date; ?></a>
    						</td>
    					</tr>
    					<?php
    				}
    				?>
  3. pncl
    Member
    Posted 2 years ago #

    if u want to put that year then u have to put static
    because year is create when post is created
    according to poet it created year

  4. Meez
    Member
    Posted 2 years ago #

    But now the menu is also generated by PHP:

    $year = isset($_POST['year']) ? $_POST['year'] : '';
    				for ($i=0; $i<5; $i++)

    Can you do something like when you click on 'Prev >>' button you get something like this:

    $year = isset($_POST['year']) ? $_POST['year'] : '';
    				for ($i=5; $i<10; $i++)

    Thanks alot

  5. pncl
    Member
    Posted 2 years ago #

    u have not put like that
    y have to put static 2007 2008

  6. Meez
    Member
    Posted 2 years ago #

    Ok but how do i link from the current field (menu/overview):

    And i don't understand because the situation now is not static, isn't it?

    2012
    2011
    2010
    2009
    2008

    to >>

    2007
    2006
    2005
    2004
    2003

    With javascript? Because you stay on the same page. You only navigate to previous Year overview...

    Thanks

  7. pncl
    Member
    Posted 2 years ago #

    i dont understood what u have to do

Topic Closed

This topic has been closed to new replies.

About this Topic