Home › Forum › Problemi Vari con WP › Stranezza con codice: bozze create a random
-
AutorePost
-
-
17 Marzo 2016 alle 9:45 #30713dad0tratt0Partecipante
Ho inserito questo snippet all’interno di function.php per far si che i post contenenti meno di 150 caratteri non vengano pubblicati, ma, non capisco perché, mi crea delle bozze automatiche ad intervalli irregolari:
function minWord($data){
if (current_user_can('editor')) {
$num = 150; //set this to the minimum number of words
if (str_word_count($data) < $num) {
$data = 'draft';
}
}
return $data;
}
add_action('wp_insert_post_data','minWord'); -
17 Marzo 2016 alle 9:46 #120119wollyAmministratore del forum
lo fa wordpress.
Se vuoi puoi disabilitarle i salvataggi automatici
-
17 Marzo 2016 alle 9:54 #120120dad0tratt0Partecipante
lo fa wordpress.
Se vuoi puoi disabilitarle i salvataggi automatici
Grazie per la risposta!
Un paio di domande:
1. Come si disattiva il salvataggio automatico?
2. Comemai, eliminando lo snippet di cui sopra, le bozze a random non vengono più create?
-
17 Marzo 2016 alle 9:58 #120121
-
17 Marzo 2016 alle 10:02 #120122dad0tratt0Partecipante
Ma comemai senza lo snippet non succede?
-
17 Marzo 2016 alle 12:01 #120125wollyAmministratore del forum
Mettimi il link da dove hai copiato quello snippet.
-
17 Marzo 2016 alle 12:32 #120127dad0tratt0Partecipante
Mettimi il link da dove hai copiato quello snippet.
http://www.wpbeginner.com/wp-tutorials/how-to-set-a-minimum-word-count-for-wordpress-posts/
-
17 Marzo 2016 alle 12:44 #120128wollyAmministratore del forum
perché hai modificato lo snippet e gli fai fare il salvataggio in draft tu, ogni volta.
-
17 Marzo 2016 alle 14:02 #120131TittiModeratore
i post contenenti meno di 150 caratteri
@dad0tratt0 Comunque è per 150 parole, non caratteri.
-
17 Marzo 2016 alle 14:11 #120132dad0tratt0Partecipante
perché hai modificato lo snippet e gli fai fare il salvataggio in draft tu, ogni volta.
La mia intenzione è quella di mandare in draft il post qualora non raggiunga un minimo di 150 parole.
Come potrei modificarlo per fare ciò?
-
17 Marzo 2016 alle 14:14 #120133dad0tratt0Partecipante
i post contenenti meno di 150 caratteri
@dad0tratt0 Comunque è per 150 parole, non caratteri.
Si, sorry, mio errore.
-
17 Marzo 2016 alle 17:15 #120138wollyAmministratore del forum
Ora non ho tempo per studiare il codice.
Ma puoi aggiungere un azione al salvataggio che lo mette in bozza se non supera i limiti che vuoi tu.
-
18 Marzo 2016 alle 9:59 #120146dad0tratt0Partecipante
Ora non ho tempo per studiare il codice.
Ma puoi aggiungere un azione al salvataggio che lo mette in bozza se non supera i limiti che vuoi tu.
Fin quଠc’ero arrivato, il problema è che non conosco PHP.
-
18 Marzo 2016 alle 11:08 #120147wollyAmministratore del forum
Se non sai scrivere codice PHP puoi copiare e utilizzare lo snippet esattamente com’è. Non salva in dreft ma non ti fa pubblicare articoli sotto quel limite.
Oppure chiedi a un professionista, non io ché non utilizzo il forum per trovare clienti, di realizzarti lo script.
Se devi modificare l’auto vai dal meccanico.
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.