Another solution would be to use an ordered list.
$my_query = new WP_Query($args);
if ( $my_query->have_posts() ) :
echo '<ol style="list-style:decimal">';
while( $my_query->have_posts() ) : $my_query->the_post();
echo '<li><a href="' . get_permalink( get_the_ID() ) . '">' . get_the_title() . '</a></li>';
endwhile;
echo '</ol>';
endif;
Related Posts:
- C++ – how to find the length of an integer
- How can I make a PHP counter?
- Counting the posts of a loop (WP_Query)?
- Category and children post count
- Hide the post count behind Post Views (Remove All, Published and Trashed) in Custom Post Type
- How to display 2 equal columns of li based on the count of items in wp_nav_menu divided by 2?
- How to cache a shortcode functions output?
- Show weekly posts statistic in WordPress
- Increasing post view count automatically [duplicate]
- Count number of posts by author in a category
- How we count the user draft posts
- server load. $_SERVER[‘REMOTE_ADDR’] and $_SERVER[‘HTTP_HOST’] [closed]
- Get count of terms with a post and another taxonomy term?
- Get Gravity Forms field values and count how many? [closed]
- Counting posts in custom post type by author
- Show ellipsis (…) only if the number of characters exceeds limit defined in substr
- How effective are cacheing plugins for dynamic pages?
- Get total views of all posts by author
- Count post + add number =
- How to do simple addition to increase favorites count of my wordpress posts
- Count posts published in one particular day: the lighter way
- Why does my site flash white every time it changes page? [closed]
- What is the best way to do this? [closed]
- Should I store critical css in the database or in my theme’s filesystem?
- Search Count WordPress Theme
- How to read out the excerpt length (for if-condition)
- What will be the best caching system for wordpress blog which has more than one million blog posts? [closed]
- $count_posts->draft & published
- CountPost WordPress Custom Taxonomy
- How to optimize ‘select found_rows()’ query? Several ‘high load average’ alerts daily
- get the count of table rows
- How to calculate posts number? [closed]
- How make animation increase of number
- Having problems getting the number of plays in a WordPress Playlist from an audio file
- How to show the amount of post that have on the site?
- Adding a posts count in archive pages
- Adding count also to parent categories
- Counting the number of elements with the values of x in a vector
- PHP 7.2 – Warning: count(): Parameter must be an array or an object that implements Countable
- How can I count the occurrences of a list item?
- How to count the occurrence of certain item in an ndarray?
- Pandas ‘count(distinct)’ equivalent
- How to sort a list of objects based on an attribute of the objects?
- Count the number of occurrences of a character in a string
- Calculate average in java
- Counting the occurrences / frequency of array elements
- Count how many files in directory PHP
- How to count the number of files in a directory using Python
- How to find length of digits in an integer?
- select count(*) from table of mysql in php
- How to get the count of each distinct value in a column?
- How to count instances of character in SQL Column
- Steps to optimize WordPress in regard to server load and website speed?
- How well does WordPress scale?
- Explanation of update_post_(meta/term)_cache
- How do you avoid caching during development?
- What are the best practices for using a caching plugin on a shared host?
- Versioning @import of parent theme’s style.css
- W3 total cache – cache refresh programmatically [closed]
- How does object caching work?
- Is this Solution for Caches vs Cookies Going to Get Me in Trouble?
- Should I use Transient API to store HTML String, or Object?
- How to mark every 3rd post
- Profiling a WordPress Website for Deployment on Shared Hosting?
- Caching: APC vs APCu vs OPcache
- Are WordPress Heartbeat API ‘beats’ staggered or do they occur simultaneously for all users?
- Best way to show Dynamic Content on a Cached WordPress Site?
- What is the best caching option for WordPress multi-site on non-shared hosting?
- Is define(‘WP_CACHE’, true) needed for object caching?
- How to cache bust a child theme style.css
- Forcing reload of editor-style.css
- Getting failure when using filemtime() with wp_enqueue_style
- Return only Count from a wp_query request?
- Prevent WordPress from sending Cache-control http header
- Restricting a Plugin to Only Load its CSS and JS on Selected Pages?
- Optimize apache for WP use
- Is get_option() faster than accessing get_transient()?
- Count & Display Database Queries
- Count posts within a custom post type and specific taxonomy and terms?
- Cache remote (HTTP) request with Transients API
- Many POST requests to /xmlrpc.php from GoogleBot taking down server?
- After Moving a Site to Another Domain, All Images Are Lost
- Is there any danger in deleting all transients?
- How to Display a List of Users Who Have Made at Least 1 Post?
- Is it possible to completely stop WP_Query retrieving posts?
- Pros and Cons for high “expire time” on wp-super-cache or w3-total-cache? [closed]
- How do I cache (core) API requests?
- Limit cache size from W3 Total Cache [closed]
- Best practices for using the transients API
- Does a query executed through wpdb class get cached?
- Caching and Versioning for rtl.css
- How do I force WordPress to show most recent version of images in the media library?
- How to Layer 7 Load Balance WordPress Backend and Frontend?
- Using transients in conjunction with memcached
- Using get_posts vs. WP_Query
- How to Display Network Post Count?
- Trouble with Transient API when W3TC is activated [closed]
- Configuring WordPress for Amazon CloudFront Caching?
- Nginx FastCGI_Cache Vs PHP Caching
- W3 Leverage browser caching not working for google pagespeed [closed]