Support

Account

Forum Replies Created

  • You’re welcome, Eagerbob. I have benefitted so much from others posting their coding solutions, it’s nice to be able to give back 😀 And thank you for catching the errors and posting about them!

  • Correction: In my original post above, the last image is wrong. It should show the what the Random Ad Radio Button Block looks like.

    Random Ad Radio Button Block

  • Ah! Thank you. That helped me figure it out. Here is my solution to show a dot if file is less than 6 months old:

    
    $age = strtotime( get_sub_field('file_date'));
    $now = strtotime("now");
    
    <span class="age"><?php if ($now - $age < 15778800) { echo "<i class='fas fa-circle'></i>"; }?></span>
    
  • I found the answer! Instead of using:

    $contactUs = get_field( "contact_form_shortcode" );
    $short = $contactUs;
    echo do_shortcode($short);

    All I needed to add was this:

    do_shortcode( get_sub_field('contact_form_shortcode') );

    Thank you for trying to help.

  • Thank you @kiwicreative for the feedback. Here is more information so you may better see the issue. The below code works except for the contact form shortcode.

    First, this is for a Board of Directors page where each board member has their own contact form, i.e., shortcode.

    Second, the counter is used for a Bootstrap4 collapse area to hide each members contact form until it is opened upon being clicked.

    The below code is working… all but the contact forms (see near bottom of code). I suspect this is because there is no differentiation between each form because the code is using $short over and over again.

    Please let me know if you need more information. And thank you!

    
    <?php
    $count = 1;
    if( have_rows('directors_and_officers') ):
    
        while ( have_rows('directors_and_officers') ) : the_row();
        $member = $count++;
        echo "<div class='officer'><div class='photo'><img src='";
            the_sub_field('photo');
        echo "' width='300' height='300' alt='Photo of ";
            the_sub_field('name');
        echo "'><h3>";
            the_sub_field('name');
        echo "</h3><h2>";
            the_sub_field('title');
        echo "</h2><p>";
            the_sub_field('phone');
        echo "</p></div><div class='bio'>";
            the_sub_field('biography');
        echo "<button class='btn btn-primary' type='button' data-toggle='collapse' data-target='#collapse-";
        echo $member;
        echo "' aria-expanded='false' aria-controls='collapse-";
        echo $member;
        echo "'>Contact ";
        the_sub_field('name');
        echo "</button>
            <div class='collapse' id='collapse-";
        echo $member;
        echo "'>
            <div class='card card-body'>";
            $contactUs = get_field( "contact_form_shortcode" );
            $short = $contactUs;
        echo do_shortcode($short);
        echo "</div></div></div></div>";
    
        endwhile;
    
    else :
        // no rows found
    endif;
    ?>
    </div><!-- #officers -->
    
  • This is my solution for anyone else wanting to use Bootstrap 3 Accordion in WordPress:

    ACF Field = “faqs”
    Repeater Sub Fields = “question”, “answer”

    
    <?php
    $counter = 1;
    if( have_rows('faqs') ):
    
     echo "<div class='panel-group' id='accordion'>";
        while ( have_rows('faqs') ) : the_row();
    
    $count = $counter++;
    
        echo "<div class='panel panel-default'>
        <div class='panel-heading'>
          <h4 class='panel-title'>
            <a data-toggle='collapse' data-parent='#accordion' href='#collapse" . $count . "'>";
            the_sub_field('question');
        echo "</a>
          </h4>
        </div>
        <div id='collapse" . $count . "' class='panel-collapse collapse'>
          <div class='panel-body'>";
          the_sub_field('answer');
        echo "</div>
        </div>
      </div>";
    
        endwhile;
    
        echo "</div>";
    else :
    endif;
    ?>
    

    Note: I’ve removed the “in” from the answer class so all panels will be closed on page load. If you want all to be open then use this instead:

    class=’panel-collapse collapse in’

  • Done. I’ll let you know when I hear back from them…

  • Is this something that you need to fix? Or should I add this finding to the support ticket I have with them?

  • Thank you. I will do what you have suggested.

  • Thank you for your reply.

    I went back and looked at all the code again and I can’t figure out what I was doing wrong before. When I did as your suggested (which I thought I had already tried) then this time it did work! Weird. In case any one else wants to know, this is what worked:

    <script type="application/ld+json">
         {
          "@context": "http://schema.org/",
          "@type": "Recipe",
          "name": "<?php the_field('recipe_name'); ?>",
          "image": "http://images.media-allrecipes.com/userphotos/600x600/1116471.jpg",
          "author": {
          "@type": "Person",
          "name": "scoopnana"
         }
         }
    </script>

    Thank you. Please mark as resolved.

  • I got it working. As what I had above was showing the taxonomy term IDs I found how to turn these IDs into text terms that could be used within $the_query $terms array. I’m not sure if this is the best way to solve the problem so if you know any way to streamline this code, I’d greatly appreciate knowing how.

    global $post;
    $row1 = get_field('homepage_sidebar_sponsor_logos' );
    $first_row = $row1[0];
    $first_row_id = $first_row['contestant_year_category' ];
    $first_row_term = get_term_by('id', absint( $first_row_id ), 'year_type');
    $first_row_name = $first_row_term->name;
    
    $row2 = get_field('homepage_sidebar_sponsor_logos' );
    $second_row = $row2[1];
    $second_row_id = $second_row['contestant_year_category' ];
    $second_row_term = get_term_by('id', absint( $second_row_id ), 'year_type');
    $second_row_name = $second_row_term->name;
    
    $row3 = get_field('homepage_sidebar_sponsor_logos' );
    $third_row = $row3[2];
    $third_row_id = $third_row['contestant_year_category' ];
    $third_row_term = get_term_by('id', absint( $third_row_id ), 'year_type');
    $third_row_name = $third_row_term->name;
    
    $the_query = new WP_Query( array(
        'post_type' => 'contestants',
        'tax_query' => array(
        array(
          'taxonomy' => 'year_type',
          'field' => 'slug',
          'terms' => array( $first_row_name, $second_row_name, $third_row_name )
        )
      ))
    ) ;
  • I figured this out. In case anyone else wants to know…

    <div class="sponsors">
    <?php
    global $post;
    $the_query = new WP_Query( array(
        'post_type' => 'contestants',
        'tax_query' => array(
        array(
          'taxonomy' => 'year_type',
          'field' => 'slug',
          'terms' => array( 'term_1', 'term_2', 'term_3' )
        )
      ))
    ) ;
    
    if($the_query->have_posts()){
        while ( $the_query->have_posts() ) {
            $the_query->the_post();
    if( have_rows('sponsors', $post->ID) ):
        // loop through the rows of data
    
        while ( have_rows('sponsors') ) : the_row();
    
            // display a sub field value
            $image = get_sub_field('sponsor_logo');
            $url = get_sub_field('sponsor_url');
            $name = get_sub_field('sponsor_name');
    
            ?>
            <div class="sponsor"><a href="<?php echo $url; ?>" target="_blank" title="<?php echo $name; ?>"><img src="<?php echo $image; ?>" /></a></div>
        <?php endwhile;
    
    else :
        // no rows found
    endif;
    }
    }
    ?>
    </div>

    Please mark this thread closed. Thank you.

  • lol. My bad. Sometimes you just overlook the obvious. Thank you!

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