Support

Account

Home Forums Add-ons Repeater Field ReferenceError: wp is not defined – Can't upload images Reply To: ReferenceError: wp is not defined – Can't upload images

  • Thank you for your reply.

    I created a wp template as you said and I named it “ACF Form” :

    <?php
    /**
     * Template Name: ACF Form
     *
     * Description: A Page Template that adds a sidebar to pages.
     *
     * @package WordPress
     * @subpackage Twenty_Eleven
     * @since Twenty Eleven 1.0
     */
    
    get_header(); ?>
    
    <form method=”post” action=”#” class=”acf-form form-horizontal ” id=”post” enctype=”multipart/form-data”>
    <?php
    $args = array(
    ‘post_id’ => ‘new’,
    ‘field_groups’ => array(1), //use wrong ID of your custom field Form so form fields will not get shown
    ‘form’ => false
    );
    acf_form($args);
    ?>
    
    <div data-field_type=”file” data-field_key=”field_5343d9b2586f0file” data-field_name=”email” class=”field field_type-text field_key-field_5343d9b2586f0file” id=”acf-file”>
    <p class=”label”><label for=”acf-field-file”>Image</label></p>
    <div class=”acf-input-wrap”>
    <input type=”file” id=”my_image_upload” name=”my_image_upload”>
    </div>
    <input id=”submit_my_image_upload” name=”submit_my_image_upload” type=”submit” value=”Submit” />
    
    <?php get_sidebar(); ?>
    
    	
    	
    <?php get_footer(); ?>

    I put the 2 functions in functions.php but I got a warning with this line :
    add_filter(‘acf/pre_save_post’ , ‘my_pre_save_post’ );
    =>Warning: Division by zero.

    I have a category called “Box 1 accueil” and I have a list of articles (actually the issue is that the images image_1 and image_2 are not displayed because the upload button for image doesn’t work.)
    Here is my code, it’s a part of the index.php page :

    <div class="accueil">
    						
    					
    						<?php	 	$esaat = "Box 1 Accueil";
    			         	$args = array('category_name' => $esaat);
    			        	$the_query = new WP_Query( $args );
    
    			         	while ( $the_query->have_posts() ) :
    			        	$the_query->the_post(); ?>   
    						
    						<div class="bandeau_bleu"><p><?php the_title();?></p></div>
    						
    						<div class="image1">
    						<img src="<?php echo the_field('image_1'); ?>" />
    						</div>
    						
    						<div class="image2">
    						<img src="<?php echo the_field('image_2'); ?>" />
    						</div>
    						
    						<div class="clr"></div>
    						<div class="titre1"><?php the_field('sous-titre');?></div>
    						
    						<div class="texte1">
    						<!--<p>
    						Le Centre éthique crée et développe des projets éducatifs et culturels internationaux. 
    						Guidé par une philosophie humaniste, il organise des rencontres interculturelles et transmet 
    						tout un ensemble de savoirs dans le sens d'une construction humaine qui respecte l'individu 
    						et son environnement.
    						Il vise ainsi à concilier par ses actions l'éthique, la science, l'art et le sacré.
    						
    					    </p>-->
    						
    						  <p><?php $content = get_the_content();print $content;?></p> 
    						
    						</div>
    							<?php
    							
    							endwhile;
    							
    							wp_reset_query();
    							wp_reset_postdata();   ?>
    						
    					
    						
    					
    						
    					</div>

    I don’t know what to do with the “ACF Form”, the template page I created. So what I have to do now please?