Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2021-04-24 17:00:32

katatonik
New Member
Registered: 2021-04-24
Posts: 2

Random article display no longer works

Hi,

I’m displaying a link to a random article on the start page of my weblog, using this code:

<txp:article_custom form=“random” limit=“1” sortby=“rand()” sortdir=“desc”/><br/>

This stopped working recently: the link no longer goes to a random article, but always to the most recent one. I also use the code on individual pages, and the behaviour there is the same.

I recently updated to 4.8.3, but I’m not quite sure whether this function stopped working because of the update.

Any help would be greatly appreciated, thanks!

Offline

#2 2021-04-24 17:18:28

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,306
Website GitHub

Re: Random article display no longer works

Hi and welcome to the forum.

Your attributes are outdated – we haven’t used sortdir and sortby for a long time so your upgrade must have been quite a jump! Try this instead, using the sort attribute:

<txp:article_custom limit="1" sort="rand() desc" form="random" />

If you put your site in Testing/Debugging mode it will show you any errors like deprecated attributes so you can hunt them down and update them.

Hope that helps.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2021-04-24 19:02:02

katatonik
New Member
Registered: 2021-04-24
Posts: 2

Re: Random article display no longer works

Ouch! Thanks a lot, this is embarrassing. Indeed, this was a nearly ancient site and a long overdue update. Problem solved.

Offline

Board footer

Powered by FluxBB