Elementor Pagination HTML
May 23, 2025 · AI Conversations
put prev in one span and numbers in one span and next in one span
### ✅ Sample HTML Structure:
<div class="custom-pagination">
<span class="pagination-prev">
<a href="#" class="prev page-numbers">Previous</a>
</span>
<span class="pagination-numbers">
<a href="#" class="page-numbers">1</a>
<span class="page-numbers current">2</span>
<a href="#" class="page-numbers">3</a>
<a href="#" class="page-numbers">4</a>
</span>
<span class="pagination-next">
<a href="#" class="next page-numbers">Next</a>
</span>
</div>
### 💡 Explanation:
– `.pagination-prev` contains the "Previous" link.
– `.pagination-numbers` wraps all the numbered page links.
– `.pagination-next` contains the "Next" link.
You can add Elementor widget class names or styles around this if you're customizing an Elementor widget or using this in a custom skin or shortcode.
Let me know if you want custom styling too!
### 🚩 Situation
You're likely using:
– A **Posts widget** or **Loop Grid** in Elementor Pro.
– Elementor auto-generates pagination as:
<div class="elementor-pagination">
<a class="page-numbers prev" href="#">←</a>
<a class="page-numbers" href="#">1</a>
<span class="page-numbers current">2</span>
<a class="page-numbers" href="#">3</a>
<a class="page-numbers next" href="#">→</a>
</div>
—
### ✅ Option 1: CSS-Only Grouping (no HTML change, fully safe)
Since you **can’t change Elementor’s pagination HTML directly**, the safest approach is to **group and style them visually using CSS**:
/* Wrap prev, numbers, and next visually */
.elementor-pagination {
display: flex;
gap: 10px;
justify-content: center;
align-items: center;
}
.elementor-pagination .page-numbers.prev {
order: 1;
margin-right: 20px;
}
.elementor-pagination .page-numbers:not(.prev):not(.next) {
order: 2;
}
.elementor-pagination .page-numbers.next {
order: 3;
margin-left: 20px;
}
You can even add pseudo wrappers like:
.elementor-pagination::before {
content: "« ";
display: inline-block;
}
.elementor-pagination::after {
content: " »";
display: inline-block;
}
—
### ✅ Option 2: Custom Loop Template (with Loop Grid)
If you use **Elementor Loop Grid**, you can:
1. Create a **Loop Item Template** (`Loop Item`) from **Templates → Loop Items**.
2. Inside your Loop template, you can customize everything except pagination.
3. The pagination is rendered after the loop, so your only way to change its structure is via **JavaScript or CSS**, unless you **build a custom shortcode or widget**.
—
### ✅ Option 3: Full PHP Custom Pagination (Advanced)
If you’re developing a **custom Elementor widget**, you can register your own pagination:
function custom_elementor_paginate_links() {
$big = 999999999; // need an unlikely integer
$paginate_links = paginate_links(array(
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'total' => $GLOBALS['wp_query']->max_num_pages,
'type' => 'array'
));
if (is_array($paginate_links)) {
echo '<div class="custom-pagination">';
echo '<span class="pagination-prev">' . array_shift($paginate_links) . '</span>';
echo '<span class="pagination-numbers">' . implode('', array_slice($paginate_links, 0, -1)) . '</span>';
echo '<span class="pagination-next">' . array_pop($paginate_links) . '</span>';
echo '</div>';
}
}
Then insert it using a shortcode or HTML widget.
—
### ✅ Summary
| Method | Editable? | Elementor Settings? | Custom Markup? |
|——–|———–|———————|—————-|
| CSS Grouping | ✅ Easy | ✅ Preserved | ❌ No change to actual HTML |
| Loop Grid + JS/CSS | ✅ | ✅ | ❌ |
| Custom PHP | ✅ Full | ❌ Manual | ✅ Yes |
Let me know what widget you're using and if you're open to using a shortcode or PHP, and I’ll tailor the method specifically.