Last active
February 19, 2019 15:43
-
-
Save taciara/6bd0d29bb35b4e846eae2484351821a2 to your computer and use it in GitHub Desktop.
depoimento ACF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //INSIRA ACIMA DA CHAMADA GET_HEADER ?> | |
<?php acf_form_head(); ?> | |
<?php //MOSTRAR OS CAMPO NO FRONT ?> | |
<?php acf_form(array( | |
'post_id' => 'new_post', | |
'field_groups' => array(3484), // ID DO SEU CAMPO PERSONALIZADO | |
'form' => true, | |
'new_post' => array( | |
'post_type' => 'depoimentos', //SLUG DO CUSTOM POST TYPES | |
'post_status' => 'pending' | |
), | |
'submit_value' => 'Enviar', | |
)); ?> | |
<?php //MOSTRAR NO SITE ?> | |
<?php | |
$args = array( | |
'post_type' => 'depoimentos', //SLUG DO CUSTOM POST TYPES | |
'order' => 'asc', | |
'orderby' => 'rand', | |
); | |
$loop = new WP_Query( $args ); | |
?> | |
<?php if ( $loop->have_posts()): ?> | |
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?> | |
<?php the_field('texto_depoimento'); ?> | |
<?php the_field('nome_depoimento'); ?> | |
<?php endwhile; ?> | |
<?php else : ?> | |
<h2>Não há depoimentos</h2> | |
<?php endif; ?> | |
<?php wp_reset_postdata(); ?> | |
<?php wp_reset_query(); ?> | |
<?php /* | |
MAIS INFORMAÇÕES: | |
LINK1: https://www.advancedcustomfields.com/resources/create-a-front-end-form/ | |
LINK2: https://www.advancedcustomfields.com/resources/acf_form/ | |
*/?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment