I can’t get it to work… My knowledge of PHP is too poor ??
This was my previous code which was working perfectly:
<?php
add_filter('uwpqsf_result_tempt', 'customize_output', '', 4);
function customize_output($results , $arg, $id, $getdata ){
// The Query
$apiclass = new uwpqsfprocess();
$query = new WP_Query( $arg );
ob_start(); $result = '';
// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
global $post;
global $wpdb;
$attachment_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post->ID' AND post_status = 'inherit' AND post_type='attachment' LIMIT 1");
$img = wp_get_attachment_url($attachment_id);
$telefono = get_post_meta(get_the_ID(), 'Telefono', true);
?>
<a href="<?php the_permalink(); ?>">
<img src="<?php echo wp_get_attachment_url($attachment_id); ?>" alt="" />
<h3><?php the_title(); ?></h3>
<p><?php echo $telefono; ?></small></p>
</a>
<?php
}
echo $apiclass->ajax_pagination($arg['paged'],$query->max_num_pages, 4, $id, $getdata);
} else {
echo 'no post found';
}
/* Restore original Post Data */
wp_reset_postdata();
$results = ob_get_clean();
return $results;
}
?>
Now I’ve tried something like this but without success even without trying to implement the maps:
<?php
add_filter('uwpqsf_result_tempt', 'customize_output', '', 4);
function customize_output($results , $arg, $id, $getdata ){
// The Query
$apiclass = new uwpqsfprocess();
$query = new WP_Query( $arg );
ob_start(); $result = '';
// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
global $post;
global $wpdb;
$attachment_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post->ID' AND post_status = 'inherit' AND post_type='attachment' LIMIT 1");
$img = wp_get_attachment_url($attachment_id);
$telefono = get_post_meta(get_the_ID(), 'Telefono', true);
$placeholder[] = array(
'post_id' => $post->ID,
'title' => $post->post_title,
//and other data you needed, you can get it from the post object.
);
$i++;
}
//you can manipulate the data in the $placeholder here.
foreach($placeholder as $key=>$val){
//put the list here.
?>
<a href="<?php the_permalink(); ?>">
<img src="<?php echo wp_get_attachment_url($attachment_id); ?>" alt="" />
<h3><?php the_title(); ?></h3>
<p><?php echo $telefono; ?></small></p>
</a>
<?php
}
//if you want to put it in gmap, may be you can manipulate the placeholder data again here.
foreach($placeholder as $key=>$val){
//blah blah blah
}
echo $apiclass->ajax_pagination($arg['paged'],$query->max_num_pages, 4, $id, $getdata);
} else {
echo 'no post found';
}
/* Restore original Post Data */
wp_reset_postdata();
$results = ob_get_clean();
return $results;
}
?>
Where am I wrong?