Support

Account

Forum Replies Created

  • I’ve managed to reduce the height of the Content block so the ACF section appear higher up the page.
    Not a solution, but might help some of you out.

    https://support.advancedcustomfields.com/forums/topic/reduce-gutenberg-content-section-height/

  • Handy solution that Keith.
    Works really well.

    Would there be a way of displaying that as a non-editable field?

  • Yes qiD
    Tried having the setting the same as yours.

    Must be something else causing it.

    Thanks for trying.

  • Hi qiD

    Tried that but it still ‘sticks’ to white even when black is selected.

    I tried changing it to
    echo $colour[‘value’];

    also tried changing it from
    array (both)
    to value

    and using your code as it is.

    very weird

    As before – it works correctly on the other pages (using my code or your new code)

  • Hi qiD
    Sorry, I’m not sure I get the relevance of that code.
    Could you explain how it would help my issue please.

    Thanks

    Dan

  • You’re right John.
    I’ll leave it up as it might help someone else

  • Solved!

    I needed to use $package->ID … of course.

    Can I delete the Post? – was just a stupid error

  • Hi John
    I ended up ‘cheating’ – I just created a true/false field for Pet Friendly.

    Not ideal as I would like to use other Facilities conditionally – things like Beachfront, Swimming Pool etc.
    I guess I can just make them true/false as well as there wont be many.

    Really appreciate all your help … I’m going to keep trying to figure it out as it’s annoying me now ha ha

    cheers

    webecho

  • No luck with that either?

    I’m using;

    <?php $pets = get_field_object('hh_facilities');
    if( isset($pets['pet']) ): ?><i title="Pet Friendly" class="fa fa-paw" aria-hidden="true">Pet</i><?php endif; ?> 

    I’ve done a var_dump and get (array of selected options):

    [14]=>
        array(2) {
          ["value"]=>
          string(3) "pet"
          ["label"]=>
          string(12) "Pet Friendly"

    and a second array (which looks to be every available option):

    ["pet"]=>
        string(12) "Pet Friendly"

    I’ve been through all the Pet Friendly properties and re-checked the Pet Friendly box as they were unchecked after changing to pet : Pet Friendly (was previously just Pet Friendly) in Choices.

    If i use !isset, then the paw shows up on all of them.
    So according to this – they are not set as having ‘pet’ checked?

    Thoroughly confused…

  • I’ve changed it to an array, but I never thought of the $pets[‘pet’] option.
    Thanks mate, I’ll try it in the morning after some Coffee.

    Really appreciate the help

    webecho

  • With return value, I’ve tried the 3 options:

    1. Value
    This works and display the label correctly ONLY if I have removed the VALUE ‘pet’ from pet: Pet Friendly in Choices.

    2. Label
    This works and display the label correctly ONLY if I have removed the VALUE ‘pet’ from pet: Pet Friendly in Choices.

    If i leave the ‘pet’ in i.e. pet: Pet Friendly
    I get Notice: Undefined index: Pet Friendly in

    3. Array (both)
    Error on every facility
    Warning: Illegal offset type in

    It appears I need to use the Array option so it can collect both the value and the label.

    If that’s the case, I’ll need to redo the code to display all the Facilities…
    which is currently:

    <?php 
    $field = get_field_object('hh_facilities');
    $value = $field['value'];
    $choices = $field['choices'];
    
    if( $value ): ?>
    <ul>
    	<?php foreach( $value as $v ): ?>
    	<li>
    		<?php echo $choices[ $v ]; ?>
    	</li>
    	<?php endforeach; ?>
    </ul>
    <?php endif; ?>
  • Could it be the return value part?

  • Hi John
    Yes, I think that’s what’s happening.

    I have changed the code to use the value instead of the label, but it’s still showing on all of them?

    <?php $pets = get_field_object('hh_facilities'); 
    if( in_array('pet', $pets) ): ?><i title="Pet Friendly" class="fa fa-paw" aria-hidden="true"></i><?php endif; ?>
  • This reply has been marked as private.
  • This reply has been marked as private.
  • The error message on screen is
    “Notice: Array to string conversion in …”

  • Hi John

    I have created a Field Group with the following inside:

    Label – Holiday Home Facilities
    name – hh_facilities
    type – checkbox
    choices –
    Air Conditioning
    BBQ facilities
    Beachfront
    Big Screen TV

    Pet Friendly

    Using the var_dump spits out the array:

    Array
    array(24) { [0]=> array(2) { ["value"]=> string(16) "Air Conditioning" ["label"]=> string(16) "Air Conditioning" }

    I am trying to check and see if the checkbox Pet Friendly is checked.
    If it is, echo Pet friendly.

  • Hi John
    hh_facilities is the Field Group containing all the checkboxes

  • Hi John
    Here’s the full page code, less a few irrelevant bits…

    <?php get_header(); ?>
    <section class="content">
    
    <?php 
    
    if (have_posts() ) {
    query_posts($query_string . '&orderby=title&order=ASC');
    	while (have_posts() ) {
    		the_post(); ?>
    		
    <?php
    
    $guests = get_field('guests');
    $bedrooms = get_field('bedrooms');
    $king = get_field('king');
    $queen = get_field('queen');
    $double = get_field('double');
    $single = get_field('single');
    $bunk = get_field('bunk');
    $trundle = get_field('trundle');
    $sofa = get_field('sofa_bed');
    $lowday = get_field('low_day');
    
    ?>		
    
    <article class="promo">
    <a href="<?php echo get_permalink(); ?>">
    <img src="<?php the_field('accom_feature_photo', $post->ID); ?>" width="100%" alt="<?php the_field('accom_name');?> - <?php single_cat_title(); ?>" >
    <?php if($lowday): ?><div class="price">from <span>$<?php echo $lowday; ?></span></div><?php endif; ?>
    <h2><?php the_field('accom_name');?></h2>
    </a>
    <section class="quick-intro">
    <?php if (has_term('dunsborough-holiday-homes', 'type')) : ?>
    <ul class="quick-info">
    <?php if ($guests): ?><li><i title="guests" class="fa fa-user" aria-hidden="true"></i> <span> <?php echo $guests; ?></span></li> <?php endif; ?>
    <?php if ($bedrooms): ?><li><i title="bedrooms" class="fa fa-bed" aria-hidden="true"></i> <span> <?php echo $bedrooms; ?></span></li> <?php endif; ?>
    
    <?php $pets = get_field('hh_facilities'); 
    if( $pets && in_array('pet', $pets) ): ?><i ti-friendly" class="fa fa-paw" aria-hidden="true"></i>Pet<?php endif; ?>
    
    </ul>
    <?php endif; ?>
    
    </section>
    
    </article>
    	
    	<?php
    		
    	} // end while
    } // end if
    ?>
    </section>
    <?php get_footer(); ?>

    Thanks for taking a look

  • Just to update.

    of course it was simple in the end…

    if  (strpos($linkout, 'booking.com') !== false){ ?>
    //do something
    } elseif (strpos($linkout, 'ezyrez.com') !== false){ ?>
    //do something else
    }

    Thanks for sending me in the right direction John

    webecho

  • Thanks John
    I have to admit, I’ve never used Switch statements so I’ll have to take a proper look at them.

    The code you’ve provided looks like it’ll do the trick.

    My last issue is that each url has a unique property identifier on it.

    i.e. booking.com?propID=1234

    I’ll have to try it out and see if I can use wildcards / regex within ACF.

    Thanks again for your help

  • Hi John
    I’ve explained my problem badly I think.

    The user can only choose a checkin and a checkout date and press ‘submit’.

    PropertyA uses BookingSiteA
    PropertyB uses BookingSiteB
    both have different syntax for selecting dates

    The user selects dates then the dates are input into a link ($bookingfield)
    on SUBMIT they are sent to that URL.

    So if the use is on PropertyA the syntax is
    http://booking.com?checkin=1/1/18:checkout=3/1/18

    If the user is on PropertyB the syntax is
    http://ezyrez.com?in=1/1/18for2nights

    PropertyA and PropertyB booking links are managed from the backend – the user can’t touch them – they’re set.

    So what I’m trying to do is find a flexible way of checking what is contained in the booking link field and depending on the result, compiling the URL in a different way.

    I’ve only given 2 examples of link syntax for simplicity, i’d like to be able to cover 7 or 8 different possibilities in an IF ELSEIF ELSE statement.

    This is the current code, that ONLY goes to booking.com

    <?php
    $linkout = get_field('accom_booking_link');
    $datein = (isset($_GET['checkin']) ? $_GET['checkin'] : null);
    $dateout = (isset($_GET['checkout']) ? $_GET['checkout'] : null);
    ?>
    
    <?php if (strpos($linkout, 'booking') !== false){ ?>
    <form id="datepick" method="GET" action="<?php echo $linkout . ';checkin=' . $datein . ';checkout=' . $dateout . ';' ?>">
    <h2>Availability</h2>
    <ul>
        <li><label>Check In </label><input type="text" id="checkin" name="checkin" value=""/></li>
        <li><label>Check Out </label><input type="text" id="checkout" name="checkout" value="" /></li>
        <li class="submit"><input type="submit" onClick="ga('send', 'event', 'BookingCom', 'availabiliity', '<?php echo $name; ?>' );"></li>
    </ul> 
    </form>
    <?php }
    ?>
  • Hi John
    $bookingfield is a url.
    field name is accom_booking_link

    So depending which website the $bookingfield ponts to, I want to present a different url structure.
    i.e. if booking.com show booking.com?checkin=1/1/18:checkout=3/1/18
    if ezyrez.com show ezyrez.com?in=1/1/18for2nights

    and so on.

    Does that make more sense?

  • Cant you just split it into 2 variables?

    $date = date(‘d-m-y’);
    $time = date(‘H:i’);

    <?php echo “” . $date . “<br/>” . $time; ?>

    Obviously don’t know the context in which you’re using it, but that should work.

    hth

    webecho

  • Solved:

    if ($school == $pagetitle)

    needed to be

    if ($school == $pagetitle) : the_row();

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