Visualizzazione 3 filoni di risposte
Visualizzazione 3 filoni di risposte
- Devi essere connesso per rispondere a questo topic.
Email: info@wpitaly.it
Home › Forum › Problemi Vari con WP › post_parent e random
ciao a tutti, uso questo codice per avere una sottopagina a caso, ora ho un piccolo problema e vorrei sapere se sto facendo nel modo corretto o no, voglio che la pagina random venga scelta non da una sola pagina madre ma da due pagine madri, di conseguenza sono passato da post_parent=531 a post_parent=531,622
in teoria cosi dovrei utilizzare due pagine madri ma non funziona, prende la sottopagina a caso anche di altre pagine mardi…
$myposts = get_posts(‘post_parent=531,622&post_type=page&orderby=rand&numberposts=1’);
dove sbaglio?
kikko088
Se non sbaglio ho visto una cosa del genere nei source di WP:
$post_parent = (int) $post_parent;
Quindi non può funzionare come pensavi.
http://codex.wordpress.org/Template_Tags/get_posts
post_parent è in integer quindi.. solo un numero ed uno solo… ergo un solo parente… dquindi fai due query separate ottieni due array di post li unisci misceli come ti pare etc.. e voilà .. ovviamente occorre conoscere un po’ di PHP
mmmm ok grazie mille
WPItaly - Copyright Creative Commons: CC BY-NC-SA 4.0