- Author: Scott Reilly
- Version: 1.4.4
- First released: 2010-09-13
- Last update: 2024-08-11
- Compatibility: WP 2.8 – 6.6.2
- Download: [ zip ]
- Description:
A variety of template tags related to the index/position of a post within a loop's listing of posts.
-
Extended Description
This plugin provides thirteen handy template tags that relate to the index/position of a post within a loop’s listing of posts.
Some of the template tags provided by this plugin relate to the position of the current post within the current loop:
c2c_is_first()
c2c_is_last()
c2c_is_at_index()
c2c_is_even()
c2c_is_odd()
c2c_get_the_index()
c2c_is_index_within()
c2c_the_index()
Other functions help you get a post (or posts) at a given position in the current loop:
c2c_get_post_by_index()
c2c_get_posts_by_index()
While the remaining three functions relate to index information about the loop in general:
c2c_get_last_index()
c2c_is_post_in_loop()
c2c_is_valid_index()
Please see the Template Tags section (in some places found under the Other Notes section) for descriptions of all the functions and their arguments.
Note that index counting begins at 0, which means the first item has an index of 0. An index of -1 indicates no posts were found.
Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage
Developer Documentation
Developer documentation can be found in DEVELOPER-DOCS.md. That documentation covers the numerous template tags provided by the plugin.
As an overview, these are the template tags provided the plugin:
c2c_get_last_index()
: Gets the index number for the last post in the loop listingc2c_get_post_by_index()
: Get post based on specified indexc2c_get_posts_by_index()
: Get posts based on specified array of indexesc2c_get_the_index()
: Get the index for the current postc2c_is_at_index()
: Is the current index at the specified index?c2c_is_even()
: Is the current post at an even position? (i.e. 0, 2, 4, …)c2c_is_first()
: Is the current post the first listed post?c2c_is_last()
: Is the current post the last listed post?c2c_is_odd()
: Is the current post at an odd position? (i.e. 1, 3, 5, …)c2c_is_index_within()
: Is the current post (or one at the specified index) within the bounds of a specified range?c2c_is_post_in_loop()
: Is the specified post within the current loop?c2c_is_valid_index()
: Is the specified index valid?c2c_the_index()
: Echo the current post’s index
Find out more at the plugin’s WordPress Plugin Repository page.
-
Installation
- Install via the built-in WordPress plugin installer. Or download and unzip
post-index-helpers.zip
inside the plugins directory for your site (typicallywp-content/plugins/
) - Activate the plugin through the ‘Plugins’ admin menu in WordPress
- Use one or more of the provided template tags in theme template file(s) as desired
- Install via the built-in WordPress plugin installer. Or download and unzip
-
Release Log
1.4.4 (2024-08-10)
- Change: Note compatibility through WP 6.6+
- Change: Update copyright date (2024)
- New: Add
.gitignore
file - Change: Reduce number of ‘Tags’ from
readme.txt
- Change: Remove development and testing-related files from release packaging
- Unit tests:
- Hardening: Prevent direct web access to
bootstrap.php
- Allow tests to run against current versions of WordPress
- New: Add
composer.json
for PHPUnit Polyfill dependency - Change: In bootstrap, store path to plugin directory in a constant
- Hardening: Prevent direct web access to
1.4.3 (2023-04-29)
- Change: Note compatibility through WP 6.3+
- Change: Update copyright date (2023)
- Fix: Fix typo for link to DEVELOPER-DOCS.md in README.md
1.4.2 (2021-10-02)
- New: Add DEVELOPER-DOCS.md and move template tag documentation into it
- Change: Note compatibility through WP 5.8+
- Unit tests:
- Change: Restructure unit test directories
- Change: Move
phpunit/
intotests/phpunit/
- Change: Move
phpunit/bin/
intotests/
- Change: Move
- Change: Remove ‘test-‘ prefix from unit test file
- Change: In bootstrap, store path to plugin file constant
- Change: In bootstrap, add backcompat for PHPUnit pre-v6.0
- Change: Restructure unit test directories
-
Copyright & Disclaimer
Copyright © 2010-2024 by Scott Reilly (aka coffee2code)This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -
Discussion / Support
Have any questions, comments, or suggestions? Please provide them via the plugin’s WordPress.org support forum. I’ll do my best to reply in a timely fashion and help as best I can.
Unfortunately, I cannot provide guaranteed support, nor do I provide support via any other means.
Was this plugin useful useful to you? Consider giving it a rating. If you’re inclined to give it a poor rating, please first post to the support forum to give me a chance to address or explain the situation.