Support

Account

Forum Replies Created

  • Appreciated.

  • Not sure why but I deleted the two datepicker fields, recreated them and now have a working date.

  • I tried adding this to query a custom post type and it gives an odd timestamp 01 January 1970:

    <?php
    $date = get_field('fromdate', false, false);
    // convert it to a time
    $time = strtotime($date);
    
    if ( get_query_var('paged') ) $paged = get_query_var('paged');  
    if ( get_query_var('page') ) $paged = get_query_var('page');
    
    $query = new WP_Query( array( 'post_type' => 'events', 'posts_per_page' => 20,  'order' => 'ASC' ) ); 
    
    if ( $query->have_posts() ) :
            
            while ( $query->have_posts() ) : $query->the_post(); ?> 
    
    <div class='events-title'>
    <span class="day"><?php echo date('d', $time); ?></span>
    <span class="month"><?php echo date('F', $time); ?></span>
    <span class="year"><?php echo date('Y', $time); ?></span>
    </div>
    
       <?php endwhile; wp_reset_postdata();
    
    else : ?>
            
            <p>There are no events at the moment</p>
    
    <?php endif;?>

    The dateformat is set up to return Ymd.

    Jon

  • Thank-you. That worked if I set the return value for the image field to a url.

    Is their a way to use the responsive elements in wordpress core to create smaller versions of the image.

    Again thanks for your help.

    Jon

  • This works for echoing out the image field but the css is not working as the width and height are being added to the inline style:

    <div class="c-1 hero bg-image" style="background-image: url('<img width=" 1024"="" height="256" src="https://devel.launchsite.co.uk/wp-content/uploads/2016/08/drama-holding-1-1024x256.jpg" alt="drama-holding" srcset="https://devel.launchsite.co.uk/wp-content/uploads/2016/08/drama-holding-1-1024x256.jpg 1024w, https://devel.launchsite.co.uk/wp-content/uploads/2016/08/drama-holding-1-300x75.jpg 300w, https://devel.launchsite.co.uk/wp-content/uploads/2016/08/drama-holding-1-768x192.jpg 768w" sizes="(max-width: 1024px) 100vw, 1024px">');">
      
      <div class="center-wrapper">
        <div class="center">
          <h1 class="cheddar">Drama</h1>
        </div>
      </div>
      
    </div>

    Using your example above. Do I need to set this line to something else:

    <div class="c-1 hero bg-image style="background-image: url('<?php echo wp_get_attachment_image( $hero, $size ); ?>');">

    regards,

    Jon

  • I tried the above change but the url is not been shown at all – the title works?

    <?php
    
    $back = get_field('bg_image');
    $size = 'full';
    if( $back ) { ?>
    
    <div class="bg-image" style="background-image: url('<?php echo $back['sizes']['full'];?>');">
    
      <div class="center-wrapper">
         <h1><?php the_title(); ?></h1>
      </div>
    </div>
    
    <?php } ?>
Viewing 7 posts - 1 through 7 (of 7 total)