SELECT
p.id as id,
p.fk_id_user,
p.fk_category,
DATE_FORMAT(p.data, '%d.%m.%Y') as data,
DATE_FORMAT(p.data_inizio, '%d.%m.%Y') as data_in,
DATE_FORMAT(p.data_scadenza, '%d.%m.%Y') as data_out,
p.data_inizio,
p.data_scadenza,
TXT_GET_MESSAGE(p.txt_titolo,'it','it') as titolo,
TXT_GET_MESSAGE(p.txt_abstract,'it','it') as estratto,
TXT_GET_MESSAGE(p.txt_text,'it','it') as corpo,
p.url_picture,
TXT_GET_MESSAGE(p.txt_mk,'it','it') as metakey,
TXT_GET_MESSAGE(p.txt_md,'it','it') as metadesc,
c.cat_it as cat
FROM ar_posts p
INNER JOIN ar_posts_categorie c
ON p.fk_category = c.id
WHERE p.published = 1 ORDER BY p.data_inizio asc?sortI=asc?sortF=asc?sortF=asc?sortF=asc?