Support

Account

Forum Replies Created

  • Thanks James! I think we’re on the same page now.

    I’m going work on implementing this tonight or tomorrow. I’ll circle back with progress soon.

    Thanks again, as always! 🙂

  • Thanks for the quick response James.

    I thought the code snippet you provided was to append display: none using a checkbox? I’m asking how to implement the true/false field to display/not display a sub field as you describe.

  • Thanks for the response James!

    So if I use true/false field how does that get implemented in the PHP code to display/not display the sub field?

  • And a little additional info…

    1. Its not kicking an error
    2.Rather its simply not printing the <?php else code:
    <h1>Sorry, we are not currently hiring. Please check back often for new opportunities with DesRosiers Architects!</h1>

  • Hi James,

    Thank you for the response.

    Here you go…

    Thanks!
    Robert

    [
        {
            "key": "group_58ad31aed23da",
            "title": "Employee Profiles",
            "fields": [
                {
                    "key": "field_58ad329495dc4",
                    "label": "Add A Profile",
                    "name": "add_profile",
                    "type": "repeater",
                    "instructions": "Add a new employee profile here",
                    "required": 0,
                    "conditional_logic": 0,
                    "wrapper": {
                        "width": "",
                        "class": "",
                        "id": ""
                    },
                    "collapsed": "field_58ad333095dc6",
                    "min": 0,
                    "max": 0,
                    "layout": "block",
                    "button_label": "Create New Employee Profile",
                    "sub_fields": [
                        {
                            "key": "field_58ad330995dc5",
                            "label": "Employee Photo",
                            "name": "employee_photo",
                            "type": "image",
                            "instructions": "Upload a photo for this employee profile here",
                            "required": 1,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "return_format": "url",
                            "preview_size": "thumbnail",
                            "library": "all",
                            "min_width": "",
                            "min_height": "",
                            "min_size": "",
                            "max_width": "",
                            "max_height": "",
                            "max_size": "",
                            "mime_types": ""
                        },
                        {
                            "key": "field_58c5abab581e3",
                            "label": "Employee Photo Alt Text",
                            "name": "employee_photo_alt",
                            "type": "text",
                            "instructions": "Add image alt text for  this profile image",
                            "required": 1,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "default_value": "",
                            "placeholder": "",
                            "prepend": "",
                            "append": "",
                            "maxlength": ""
                        },
                        {
                            "key": "field_58ad333095dc6",
                            "label": "Employee Name",
                            "name": "employee_name",
                            "type": "text",
                            "instructions": "Enter the employee's name here",
                            "required": 1,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "default_value": "",
                            "placeholder": "i.e. John Doe",
                            "prepend": "",
                            "append": "",
                            "maxlength": ""
                        },
                        {
                            "key": "field_58ad33cc95dc7",
                            "label": "Job Title",
                            "name": "job_title",
                            "type": "text",
                            "instructions": "Enter the job title for this employee here",
                            "required": 1,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "default_value": "",
                            "placeholder": "i.e Architect",
                            "prepend": "",
                            "append": "",
                            "maxlength": ""
                        },
                        {
                            "key": "field_58ad340895dc8",
                            "label": "Bio",
                            "name": "employee_bio",
                            "type": "textarea",
                            "instructions": "Enter a short bio for this employee here",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "default_value": "",
                            "placeholder": "",
                            "maxlength": "",
                            "rows": "",
                            "new_lines": ""
                        },
                        {
                            "key": "field_58c5a9d2b1522",
                            "label": "Profile Slug",
                            "name": "profile_slug",
                            "type": "text",
                            "instructions": "Enter a link slug for this profile here. This must be all lower-case with no spaces.",
                            "required": 1,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "default_value": "",
                            "placeholder": "i.e. louisdesrosiers",
                            "prepend": "",
                            "append": "",
                            "maxlength": ""
                        }
                    ]
                }
            ],
            "location": [
                [
                    {
                        "param": "options_page",
                        "operator": "==",
                        "value": "employee-profiles"
                    }
                ]
            ],
            "menu_order": 0,
            "position": "normal",
            "style": "default",
            "label_placement": "top",
            "instruction_placement": "label",
            "hide_on_screen": "",
            "active": 1,
            "description": ""
        }
    ]
  • That’s what I thought. I’m still not getting anything. I think it might be that I’m running multisite.

    So…

    I have 1 site that I’ve created the ensighten tag field for and placed it on an options page for that site. Its called in the global header from there. Its NOT showing up in the site that I have the options page setup for and NOT on any of the child sites.

    Could that be the source of the problem?

    I’ve double checked the slug name again and again. Its solid.

    <?php the_field ('ensighten_tag', 'option'); ?>

  • Thanks for the response!

    But I want this to appear on all pages so it needs to populate somewhere globally.

  • That did the trick! Thanks a ton for all your help James!

  • Thanks! Then I can just call the custom fields in the page template that the post type uses?

  • Figures it out. It was the spaces in my_acf_admin_head. Cleaned it up like this…

    <?php function my_acf_admin_head() {
        $backgroundimage = get_field('background_image', 'option'); ?>
        <!--BEGIN USER INPUT STYLES-->
        <style type="text/css">
            /**Adds custom global background image**/
            .main-content {
                background-image: url(<?php echo $backgroundimage; ?>);
            }
        </style>
    <?php } add_action('wp_head', 'my_acf_admin_head'); ?>
  • That’s super helpful! Thank you!

  • Any chance you might have a little more detail on how I would implement that along with ACF options functions? Would I wrap the acf options function in this function with the specific blog ID called? Thanks a ton!

  • Finally figured it out. Hope this helps someone else out!

    <!--ORBIT SLIDE-->
    <?php
    if (have_rows('add_resorts_hero_image_slide', 'option')) {
        while (have_rows('add_resorts_hero_image_slide', 'option')) {
            the_row();
    
                if (have_rows('choose_resorts_hero_slider_content')) {
                    while (have_rows('choose_resorts_hero_slider_content')) {
                    the_row();
                        
                    $herovideo = get_sub_field('add_resorts_hero_slider_video');
                    $heroimage = get_sub_field('add_resorts_hero_slider_image');
                    $heroimgsize = 'hero-image';
                    $heroimg_array = wp_get_attachment_image_src($heroimage, $heroimgsize);
                    $heroimg_url = $heroimg_array[0];
    
                        if( get_row_layout() == 'resorts_slider_video' ) {
                            
                        echo '<li class="video orbit-slide">';
                        echo '<img class="background" src="http://localhost.com/vail/tier2-hero-placeholder.jpg" />';
                            
                           echo '<div class="container">
                            <div class="watermark"></div>
                            <iframe id="heroorbitslider-video"
                              src="'. $herovideo .'"
                              width="100%" 
                              frameborder="0" 
                              scrolling="no" 
                              allowFullscreen="true" 
                              allowFullScreen="true" 
                              webkitAllowFullScreen="true" 
                              mozAllowFullScreen="true">
                            </iframe>
                            </div>';
                            
                        echo '</li>';
                        }
                        
                        elseif( get_row_layout() == 'resorts_slider_image') {
                            
                            echo '<li class="orbit-slide">';
                                echo '<img class="background "src="'. $heroimg_url .'" />';
                            echo '</li>';
                        }
    
                    }
    
                }
    
        }
    
    }
    
    ?>
    <!--END ORBIT SLIDE-->
  • You think so? I’ve tried the exact path hardcoded and it is still kicking it back as an invalid property value. Its proper CSS. That leads me to believe that its something to do with the function.

  • You think so? I’ve tried the exact path hardcoded and it is still kicking it back as an invalid property value. Its propert CSS. That leads me to believe that its something to do with the function.

  • Ok. Reset it back to URL and removed the quotes around the php echo. Still the same problem. Its printing the URL fine but says its an invalid property value.

    Thanks a ton for helping troubleshoot this!

    This is where it is now..

    <!--USER INPUT STYLES FUNCTION-->
        <?php function my_acf_admin_head() {
        
            $backgroundimage = get_field('background_image', 'option');
        
            ?>
            <!--BEGIN USER INPUT STYLES-->
            <style type="text/css">
                
                /**Adds custom global background image**/
                .main-content {
                    background: url ("<?php echo $backgroundimage; ?>");
                }
                
            </style>
            <?php
        }
        add_action('wp_head', 'my_acf_admin_head');
        ?>
        <!--END USER INPUT STYLES-->
  • Changed the image field to ID and calling it this way now…still getting invalid property value.

    <!--USER INPUT STYLES FUNCTION-->
        <?php function my_acf_admin_head() {
        
        $backgroundimage = get_field('background_image', 'option');
                $backgroundimgsize = 'full';
                $backgroundimg_array = wp_get_attachment_image_src($backgroundimage, $backgroundimgsize);
                $backgroundimg_url = $backgroundimg_array[0];
        
            ?>
            <!--BEGIN USER INPUT STYLES-->
            <style type="text/css">
                
                /**Adds custom global background image**/
                .main-content {
                    background: url ("<?php echo $backgroundimg_url; ?>");
                }
                
            </style>
            <?php
        }
        add_action('wp_head', 'my_acf_admin_head');
        ?>
        <!--END USER INPUT STYLES-->
  • Ah ha! Thank you!

    It is now adding the style but it says its an invalid property value. I’m assuming this is because I have the field set to URL? Maybe by ID would be a better solution?

    The php echo is printing this and saying it is an invalid property value…

    .main-content {
    background: url ("http://localhost.com/vail/mountain-exploration/wp-content/uploads/sites/2/2016/09/vail-resorts-epic-ski-tracks-main-content-background.jpg");
    }
  • I want the user to be able to add a background image globally to the front end of the website, attached to a class called .main-content, which is a primary content container for the website, as a style background-image: url(”);.

    The custom image field is all setup in the admin area. The image is uploaded. The custom field included in the functions.php is the one.

    So am I understanding the admin head styles incorrectly? This is used to style the admin area only? This is the only piece of the docs I’ve been able to find that even closely resembles how to approach the problem. And I’m sure I’m missing something completely obvious! 😛

    What’s the best to include acf custom fields into css aside from HTML inline element css?

  • Do you mean the WP admin dashboard for the site? If so, not seeing anything in the <head>.

    I’m using Multisite. Could that impact how this will work?

  • Nothing is showing up at all. The background-image style on class .main-content is not appearing as a result of adding the above code to functions.php.

  • This is what I have so far. Its not pulling in the content associate with the custom fields…

    <!--ORBIT SLIDE-->
    <?php
        if (have_rows('add_resorts_hero_image_slide', 'option')) {
            while (have_rows('add_resorts_hero_image_slide', 'option')) {
                the_row();
                
                $herovideo = the_sub_field('add_resorts_hero_slider_video');
                $heroimage = the_sub_field('add_resorts_hero_slider_image');
                    $heroimgsize = 'hero-image';
                    $heroimg_array = wp_get_attachment_image_src($heroimage, $heroimgsize);
                    $heroimg_url = $heroimg_array[0];
                
    
                if (have_rows('choose_resorts_hero_slider_content')) {
                    while (have_rows('choose_resorts_hero_slider_content')) {
                    the_row();
                
                        echo '<li class="orbit-slide">';
    
                        if( get_row_layout() == 'resorts_slider_video' )
    
                            echo $herovideo;
                            
                        elseif( get_row_layout() == 'resorts_slider_video')
                            echo '<img src="'.$heroimg_url.'" />';
                        
                        echo '</li>';
    
                    }
                } 
         }
    }
    
    ?>
    <!--END ORBIT SLIDE-->
  • Thanks James!

    But if I simply add the sub_field the way you have it it won’t embed into HTML, right? For instance, don’t I need to have the image subfield embedded in src=”” ? Thats why I was setting them as variables up top and then was planning on echoing the variable in the loop. But how would I echo it in an img src=”” tag within the loop?

  • Ok, here’s what I’ve come up with for the code. Its completely breaking my page. Hmmmmm…any help would be very appreciated. Thanks!

    <?php
        if (have_rows('add_resorts_hero_image_slide')) {
            while (have_rows('add_resorts_hero_image_slide')) {
                the_row();
        
        if (have_rows('choose_resorts_hero_slider_content')) {
            while (have_rows('choose_resorts_hero_slider_content')) {
                    : the_row();
    
           echo '<li class="orbit-slide">'
            
           if( get_row_layout() == 'resorts_slider_video' ):
    
            	the_sub_field('add_resorts_hero_slider_video');
    
            elseif( get_row_layout() == 'resorts_slider_video' ): 
    
            	the_sub_field('add_resorts_hero_slider_image');
        
          } 
        }
       echo '</li>'
      } 
    }
    ?>
Viewing 25 posts - 1 through 25 (of 25 total)