Support

Account

Forum Replies Created

  • Got it!

    //add default blocks to the content
    function indewalvis_post_block_template() {
    	$post_type_object = get_post_type_object( 'page' );
    	$post_type_object->template = array(
    		array( 'acf/slideshow' ),
    		array( 'core/heading', array( 'level' => 1 ) ),
    		array( 'core/paragraph' ),
    	);
    }
    add_action( 'init', 'indewalvis_post_block_template' );
  • oi… just add the post->ID to get_field does the trick

  • Thanks @enky that’s exact what I needed, works like a charm!

  • Hi @eberger3,
    No I didn’t!
    But what worked for me was using the location data. So do a search and then get the all the place details, here is my code, enjoy.
    Jonas

    
    $('.hotspots-details').each(function(){
    	var location = $(this).attr('data-location');
    	
    	if(location){
    		var request = {
    			query: location
    		};	
    		var service = new google.maps.places.PlacesService(map);
    		service.textSearch(request, callbacksingle);
    	}
    });
    

    and then something like:

    
    function callbacksingle(results, status) {
    	
    	if (status == google.maps.places.PlacesServiceStatus.OK) {
    
    		var service = new google.maps.places.PlacesService(map);
            service.getDetails({
              placeId: results[0].place_id
            }, function(place, status) {
            	if (status === google.maps.places.PlacesServiceStatus.OK) {
    			
    				//console.log(place);
    
    				var output;
    				output = '';
    					
    				//address
    				if(place.adr_address){
    					output += '<h3>Adres</h3>';
    					output += place.name+'<br>';
    					address = place.adr_address.split(', ');
    					for(var i=0; i<address.length; i++){
    						output += address[i]+'<br>'; 
    					}
    				}
    				
    				//phonenumber
    				if(place.formatted_phone_number){
    					output += '<a href="tel:'+place.formatted_phone_number+'">'+place.formatted_phone_number+'</a><br>';
    				}
    				
    				//website
    				if(place.website){
    					output += '<a href="'+place.website+'">'+place.website+'</a><br>';
    				}  
    	          
    				output += '';
    	          
    				//output everything
    				$('.google-data').append(output);
            	}
            });	
    	}
    }	
    
  • Hello Jusseb,
    No solution yet, but a nasty workaround, a large query.
    If somebody knows how to make the numbers generic we would have the solution 😉

    Here is my nasty, way too long query:

    $querystr = ”
    SELECT DISTINCT wposts.*
    FROM $wpdb->posts wposts
    LEFT JOIN $wpdb->postmeta wpm1 ON (wposts.ID = wpm1.post_id
    AND wpm1.meta_key = ‘tijdblok_0_start_tijd’)
    LEFT JOIN $wpdb->postmeta wpm2 ON (wposts.ID = wpm2.post_id
    AND wpm2.meta_key = ‘tijdblok_0_eind_tijd’)
    LEFT JOIN $wpdb->postmeta wpm3 ON (wposts.ID = wpm3.post_id
    AND wpm3.meta_key = ‘tijdblok_1_start_tijd’)
    LEFT JOIN $wpdb->postmeta wpm4 ON (wposts.ID = wpm4.post_id
    AND wpm4.meta_key = ‘tijdblok_1_eind_tijd’)
    LEFT JOIN $wpdb->postmeta wpm5 ON (wposts.ID = wpm5.post_id
    AND wpm5.meta_key = ‘tijdblok_2_start_tijd’)
    LEFT JOIN $wpdb->postmeta wpm6 ON (wposts.ID = wpm6.post_id
    AND wpm6.meta_key = ‘tijdblok_2_eind_tijd’)
    LEFT JOIN $wpdb->postmeta wpm7 ON (wposts.ID = wpm7.post_id
    AND wpm7.meta_key = ‘tijdblok_3_start_tijd’)
    LEFT JOIN $wpdb->postmeta wpm8 ON (wposts.ID = wpm8.post_id
    AND wpm8.meta_key = ‘tijdblok_3_eind_tijd’)
    LEFT JOIN $wpdb->postmeta wpm9 ON (wposts.ID = wpm9.post_id
    AND wpm9.meta_key = ‘tijdblok_4_start_tijd’)
    LEFT JOIN $wpdb->postmeta wpm10 ON (wposts.ID = wpm10.post_id
    AND wpm10.meta_key = ‘tijdblok_4_eind_tijd’)
    LEFT JOIN $wpdb->postmeta wpm11 ON (wposts.ID = wpm11.post_id
    AND wpm11.meta_key = ‘tijdblok_5_start_tijd’)
    LEFT JOIN $wpdb->postmeta wpm12 ON (wposts.ID = wpm12.post_id
    AND wpm12.meta_key = ‘tijdblok_6_eind_tijd’)
    WHERE (
    (wpm1.meta_value <= $hour) AND (wpm2.meta_value > $hour)
    OR
    (wpm3.meta_value <= $hour) AND (wpm4.meta_value > $hour)
    OR
    (wpm5.meta_value <= $hour) AND (wpm6.meta_value > $hour)
    OR
    (wpm7.meta_value <= $hour) AND (wpm8.meta_value > $hour)
    OR
    (wpm9.meta_value <= $hour) AND (wpm10.meta_value > $hour)
    OR
    (wpm11.meta_value <= $hour) AND (wpm12.meta_value > $hour)
    )
    AND wposts.post_type = ‘programma’
    AND wposts.post_status = ‘publish’
    ORDER BY wpm1.meta_value ASC
    “;

  • Got a “dirty” solution for just 4 timeslots. Is there somebody who knows how to make this query generic?

    Lots of thank you’s in advance!!!

    global $wpdb;
    global $post;
    $querystr = ”
    SELECT DISTINCT wposts.*
    FROM $wpdb->posts wposts
    LEFT JOIN $wpdb->postmeta wpm1 ON (wposts.ID = wpm1.post_id
    AND wpm1.meta_key = ‘tijdblok_0_start_tijd’)
    LEFT JOIN $wpdb->postmeta wpm2 ON (wposts.ID = wpm2.post_id
    AND wpm2.meta_key = ‘tijdblok_0_eind_tijd’)
    LEFT JOIN $wpdb->postmeta wpm3 ON (wposts.ID = wpm3.post_id
    AND wpm3.meta_key = ‘tijdblok_1_start_tijd’)
    LEFT JOIN $wpdb->postmeta wpm4 ON (wposts.ID = wpm4.post_id
    AND wpm4.meta_key = ‘tijdblok_1_eind_tijd’)
    LEFT JOIN $wpdb->postmeta wpm5 ON (wposts.ID = wpm5.post_id
    AND wpm5.meta_key = ‘tijdblok_2_start_tijd’)
    LEFT JOIN $wpdb->postmeta wpm6 ON (wposts.ID = wpm6.post_id
    AND wpm6.meta_key = ‘tijdblok_2_eind_tijd’)
    LEFT JOIN $wpdb->postmeta wpm7 ON (wposts.ID = wpm7.post_id
    AND wpm7.meta_key = ‘tijdblok_3_start_tijd’)
    LEFT JOIN $wpdb->postmeta wpm8 ON (wposts.ID = wpm8.post_id
    AND wpm8.meta_key = ‘tijdblok_3_eind_tijd’)
    WHERE
    (
    (wpm1.meta_value <= $hour) AND (wpm2.meta_value > $hour)
    OR
    (wpm3.meta_value <= $hour) AND (wpm4.meta_value > $hour)
    OR
    (wpm5.meta_value <= $hour) AND (wpm6.meta_value > $hour)
    OR
    (wpm7.meta_value <= $hour) AND (wpm8.meta_value > $hour)
    )
    AND wposts.post_type = ‘programma’
    AND wposts.post_status = ‘publish’
    ORDER BY wpm1.meta_value ASC
    “;

    $wpdb->show_errors();
    $result = $wpdb->get_results($querystr);

    foreach ($result as $post):
    setup_postdata($post);
    get_template_part(‘loop-programma’);
    endforeach;

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