Support

Account

Forum Replies Created

  • Thanks for your replies. @anybodesign I’ll take a look. This will shed some light for me.

  • Ok, thanks for your reply and I can’t believe I’m starting to get some of this. HOWEVER, what I put into the post-template doesn’t work (and am happy that it doesn’t break the page).

    Here’s what I inserted…two instance, neither of which work to NOT SHOW when the true/false field is unchecked.

    <?php // profession drop down with multiple selection option - vars	
    
    	$profession = get_field('profession');
    
    // check
    if( display_profession_on_public_listing == true && $profession ): ?>
    <div class="professions"><?php echo implode(', ', $profession); ?></div>
    <?php endif; ?>
    <?php if( display_profession_on_public_listing == true && get_field('alt_profession') ): ?>
    	<div class="otherProfession"><?php the_field('alt_profession'); ?></div>
    <?php endif; ?>	

    First of these is a drop-down and the second one is a text-field (single line).

  • This gets me started. Is there a way to wrap everything in a container div and add an IF statement so it isn’t added if there are no values entered (i.e. nothing is checked)? Newbie here breaking things trying to figure it out.

  • This is a big help. I’m on my way so I’ll mark this as solved and hope I can follow through. Many thanks for your patience and kindness.

  • I don’t follow you. It’s a stretch beyond my comfort zone, I suppose.
    I have this working (adapted from ACF website snippet):

    <?php 
    
    $image = get_field('photo102');
    
    if( !empty($image) ): 
    
    	// vars
    	$url = $image['url'];
    	$title = $image['title'];
    	$alt = $image['alt'];
    	$caption = $image['caption'];
    
    	// thumbnail
    	$size = 'member-listing';
    	$thumb = $image['sizes'][ $size ];
    	$width = $image['sizes'][ $size . '-width' ];
    	$height = $image['sizes'][ $size . '-height' ];
    
    	if( $caption ): ?>
    
    		<div class="wp-caption">
    
    	<?php endif; ?>
    
    	 <!--  see single-cdtxprofessional.php in this area for code for adding link to picture itself if you want that -->
    
    		<img src="<?php echo $thumb; ?>" alt="<?php echo $alt; ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>" />
    
    	</a>
    
    	<?php if( $caption ): ?>
    
    			<p class="wp-caption-text"><?php echo $caption; ?></p>
    
    		</div>
    
    	<?php endif; ?>
    
    <?php endif; ?>

    So, if the user doesn’t add an image here, I would like a default alternate. If I do the global ACF options method, I’m not clear on how I add the function with a priority less than 99. Also don’t know where I put such code, in theme functions or a plugin? Sorry, as I’m a bit green here.

  • I think it should be something simple in the interface and something clearly outlined in the documentation. This working in the admin area is a very helpful feature, but I would think that if it can be applied to the admin area, it could (or might be intended to) be applied to the front end as well. Not knowing ACF’s intent, both Eric and I were held up by a common, errant assumption.

  • Ok, thanks Jonathan. That explains the purpose of the wrapper attributes. But Eric, does this help with your original questions? #2 – Adding the numbers after the class isn’t addressed yet. Not sure about the others, #1 and #3.

  • I mean the line in the ACF editor of any field or subfield, at or near the bottom under Conditional Logic. Under “Wrapper Attributes”, there is an entry for width, class, and ID. I assumed this was intended to wrap a div around the field area with a value for width or a name for class or ID.

  • I was posing my example as a possible solution for Eric on his issue that I also experience where adding an ID or a CLASS to the field’s wrapper attributes seems to have no affect. I put a div tags in HTML into the post-type template to do what I expect the wrapper attributes values to accomplish. Are we correct in assuming that the wrapper attributes would wrap the field in a div?

  • I’ve been struggling also. I can’t get the wrap properties to do anything. If you figured this out, please let me know here. I can get the repeater subfields to work and I can put a div around the repeater in the PHP of the custom post type file I’m using:

    First, I have ACF installed and other fields are working. Repeaters are set up with Field Label and Field Name that ACF inserts by default, Field Name has no spaces, uses underscores between words (and I think hyphens are allowed, too.)

    In my instance, I only am using one sub-field per repeater and it’s field type is set to “text”.

    Here is my PHP used in the template file. You can see where I stop PHP to insert div tags with HTML, then restart PHP:

    <!-- education listings -->
    
    <?php
    
    // check if the repeater field has rows of data
    if( have_rows('education_listings') ): 
    
    // loop through the rows of data
    ?>
    	<div class="educationBlock"><h2>Education</h2>
    	
      <?php  while ( have_rows('education_listings') ) : the_row(); ?>
    	<div class="educationListing">
    	<?php
            // display a sub field value
            the_sub_field('education_list_item');
    	?>
    	</div> 
    	<?php
        endwhile; ?>
        </div>
        <?php
    
    else :
    
        // no rows found
    
    endif;
    
    ?>
    
    <!-- end education listings -->
  • That’s amazing, John. Thanks. I’ll have to study it awhile.

  • Brand new here and not much of a coder. Do you know where I could get started learning what you described? I don’t know how the filter would look. I don’t know what before and after ACF means in practice. I don’t know how to compare (what that command would be) and how to send an email to the admin. I follow your thought process and assume it could work but am very basic in my PHP skills.

    I’m asking for something I can only vaguely understand so that being said, do know where I might look to get started on any of these items?

    Sorry that I’m very rudimentary.

  • I see the link working now. I hadn’t visited this section before but will. I’ll mark this post as resolved although I don’t have it working yet. Being a little green, I’ll take some time with this. Thanks for your help, John. This chart is very helpful, taken from your link’s sidebar.

    https://developer.wordpress.org/files/2014/10/wp-template-hierarchy.jpg

  • Thanks, John. I have the file itself working, single-somename.php. And can get the custom post type to register in the backend but I need to learn more on making it behave with all functionality that regular posts have. That is to say, having meta data such as author name, date, etc, taxonomy type display and all. I have it now set up so that I can create the taxonomies (taking the place of “categories” for standard posts) but they don’t seem to display in the site itself. That is to say, I can’t show the archive of a taxonomy I created in the admin area.

    I believe that’s related to standard WordPress code in functions.php. What I have listed above in functions.php is a start but I believe more is needed to make all aspects work properly.

    I am also reaching out to the Studio Press community but no working replies as yet. Probably need more time. Thanks again for your reply.

Viewing 14 posts - 1 through 14 (of 14 total)