Support

Account

Forum Replies Created

  • This should do the trick. Simply add it to your functions document. the \n is a line break to make your code look nicer when it spits it out.

    
    add_action('wp_enqueue_scripts', 'customJsFunction'); 
    function customJsFunction(){
    	global $post;
    	$script= get_field('header_script',$post->ID);
    	if($script){
    		echo '<script>'."\n".$script."\n".'</script>'."\n";
    	}
    }
  • If you can, simply change your page link field type to a Post Object. You can then set your post type in the settings to page which will give you the same page selection on your form. You can then use the code below to get the title as you wanted.

    
    <?php 
    $links = get_field('procedure_list');
    if( $links ): ?>
        <h3 class="procedures-menu_header">Procedures</h3>
    	<ul class="procedures-menu_list">
        <?php foreach( $links as $link): ?>
            <li>
                <a href="<?php echo get_permalink($link->ID); ?>"><?php echo get_the_title($link->ID); ?></a>
            </li>
        <?php endforeach; ?>
        </ul>
    <?php endif;
    
    ?>
  • I have not tested this all out but it should work for you.

    With a custom field image

    <?php
    $image = get_field('image');
    $custom_image_url = get_field('customURL', $image['ID']);?>
    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" data-attr="<?php echo $custom_image_url;?>" />
    

    With a featured image

    <?php
    $url = get_the_post_thumbnail_url( $post->ID );
    $thumbnail_id = get_post_thumbnail_id( $post->ID );
    $custom_image_url = get_field('customURL', $thumbnail_id);
    $alt = get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true);
    ?>
    <img src="<?php echo $url; ?>" alt="<?php echo $alt;?>" data-attr="<?php echo $custom_image_url;?>" />
  • The following code can be placed at the bottom of your functions.php document. It will loop through all your posts within that post type and set fl_flag to 1/true. You can delete it after viewing any page once. If the field fl_flag does not exist in the post it will create the field.

    $args=array(
    	'posts_per_page' => -1,
    	'post_type' => 'events'
    );
    $the_query = new WP_Query( $args );
    if ( $the_query->have_posts() ) :
    	while ( $the_query->have_posts() ) : $the_query->the_post();
    		update_field('fl_flag', '1', get_the_ID());
    	endwhile;
    endif;
    
  • We need more information about your code in order to help you. What type of field is it? what do you get when you dump $values; Is this code on a templates page? Are you including it within the loop? Are you pulling it from a different post or user?

    I would also suggest in the future to use “\n” for line returns rather than physical line returns in apostrophes.

  • You have a couple options depending on what your needs are.

    1. Create a PDF from a url: http://phptopdf.com/
    2. Create PDF solely with php: http://www.fpdf.org/
  • You can use the acf_save_post to update the field.
    https://www.advancedcustomfields.com/resources/acf-save_post/

    The following function would disable the field on load.

    add_filter('acf/load_field/name=field_name', 'sampleFunction');
    function sampleFunction( $field ){ $field['disabled']='1'; return $field; }
Viewing 7 posts - 26 through 32 (of 32 total)