A MOD for Previous and Next Navigation for Single ADS Pages -- single-default.php
My MOD for Previous and Next Navigation for Single ADS Pages -- single-default.php
I came in here weeks ago forthrightly and courageously demanding some New Features !
(whimpering and begging, to tell the truth . .. )
So, I decided to go make something for myself that did pretty much the same thing that I thought would be useful for Users of Classipress, that is, End Users.
I wanted something similar to the Breadcrumbs, and similar to the Main Category listings that are paginated after the Ad Category listings reach their page display limit, such as 5 or 10, whatever, and show you the little "Page 1 of 3 " 1 | 2 | 3 |
What I wanted was this:
The user is in a certain Ad category, such as, "Hitmen for Hire".
They see a vertical list of returned Vets ready for some mercenary action with their newly acquired technical skills.
The user selects an Ad entitled "Have AK-47, Will Travel"--
Up pops our Ad with all the gory particulars.
Underneath the Breadcrumb:
Home » Assassins & Mercenaries » Affordable Contractors » Have AK-47, Will Travel
I wanted something like this
« See an Older Ad in this category << 21 Ads in this Category >> See a Newer Ad in this category »
Click on the "Older Ad" or click on the "Newer Ad" and the NEXT AD IN THIS SAME CATEGORY DISPLAYS withOUT NEEDING to RETURN to the Starting page of the Category Ads.
This little NAVIGATION AID keeps track of the Next Ad and the Next Ad every time the Single Ad display page loads.
INSTEAD OF GOING BACK TO THE MAIN CATEGORY LIST OVER AND OVER TO PICK ANOTHER AD !!
So, that is what I made using regular pre-existing WordPress functions...it's simple and You are welcome to use this code--
So here is the MOD to make looking at individual ads in a category FASTER...
It can be modded further to respond to different needs and characteristics.
But here is a version that works well for me.
Open up the Single-default.php file in any version of Classipress from 3 on... 01..02..03..04
In the virgin file, in 3.0.4, for instance you will find these lines:
PHP Code:
line 19: <div id="breadcrumb">
<?php if(function_exists('cp_breadcrumb')) cp_breadcrumb(); ?>
</div>
line 25: <div class="content_left">
So, here is the code to replace that--
PHP Code:
<div id="breadcrumb">
<?php if(function_exists('cp_breadcrumb')) cp_breadcrumb(); ?>
</div>
<?php
$category = get_the_category();
?>
<div id= "mynavlinks"> <?php previous_post_link('%link', '« See an Older Ad in this category', TRUE, '3'); ?> <?php echo '<< ' .$category[0]->category_count . ' Ads in this Category >>'; ?> <?php next_post_link('%link', 'See a Newer Ad in this category »', TRUE, '3');?></div>
<div class="content_left">
Save it and upload it and see what you get.
Go to any Ad category...such as the archive listing of all posts/ads in one of your categories that has the MOST listings.
Drill in to the middle of the pack and select one ad to look at, click on it, look at it now as a single Ad, all by its lonesome.
IF you are using the Breadcrumb in your navigation then you should see some new lines indicating how many ADs are in THIS category.
If you are in a Parent Category, it will list all ads in that Parent category.
If you are in a Sub-category it will list all Ads in that Sub-category.
This mod is set up to simply accept the default...which is that the date an ad is posted determines where it shows up in the whole forward and back.
I gave this a Div ID so that you can write specific CSS code to apply to just this Navigation Aid.
That's it. Nothing will blow up if you want to drop this code in to your single-default.php page. Save the original single-default.php and be ready to upload it if you decide not to use this mod code.