Archived topic
How to modify the read-more link on a particular page?
4 replies · Started by Jean-Pol on December 9, 2019
On a specific page that lists a series of posts from a request (title + thumbnail + excerpt), I want to add as a GET parameter at the end of the URL to the full article (a string with the list of article IDs present on the page).
At the end of get_the_permalink I can add my settings.
On the other hand, get_the_excerpt automatically generates the "More" button, and there, I do not see how to add my parameter behind the permalink ...
I tried to add a filter found on the codex, but it does not change anything ...
I need your help here ...
Hi there,
I'm not sure I fully understand. Can you explain a bit more?
Are you wanting to edit the read more link only when the GET parameter is present? Would you be removing it or only tweaking it?
Let me know :)
Here is my current code, very cleaned. I use the Search & Filter Pro plugin, and I try to modify the display results template.
On a page, I have in a column my search form and on the right the result of the query created by selecting checkboxes in the search form.
When my request selects for example 3 posts, I wish, by clicking on the title or more button to open the complete post on a page, with in a column a list containing the 3 titles of the posts of my selection. This allows to navigate in the result of my selection ...
I was wondering how to move the list of posts from my selection from one page to another ... I imagined by a variable GET, but there is perhaps a better solution, simpler, or more elegant ...
<?php
/**
* Search & Filter Pro template
*/
// GET ALL THE IDS OF THE SEARCH RESULT
if ($query->max_num_pages == 1) {
$idsurl = '?ids=';
while ($query->have_posts()) {
$query->the_post();
$idsurl .= get_the_ID() . ',';
}
$idsurl = rtrim($idsurl, ',');
}
// DISPLAY THE SEARCH RESULT AND PASS ALL THE IDS TO THE SINGLE POST PAGE IN GET URL ATTRIBUTE
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
?>
<div>
<h2><a href="<?php the_permalink(); // ADD HERE THE IDS IN THE URL
echo $idsurl; ?>"><?php the_title();?></a></h2>
<p><?php the_excerpt(); // HOW ADD THE IDS IN THE MORE BUTTON URL ???? ?>
</p>
</div>
<?php
}
?>
I found a solution using $_SESSION (and the WP session manager plugin), instead of $_GET.
Awesome! Glad you got something working :)