Custom mashup query on search page

Home Forums MapPress Support Custom mashup query on search page

Tagged: , ,

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #13249
    bazel
    Participant

    Hi
    I have a custom db query on search page that search through post titles or post slugs. Mappress mashup is set to get the posts from that query and this is working good when posts are searched by title(like the normal search on wordpress) but the map is not showing when I search from slug. here is the loop

     <?php
     $s = get_query_var('s');
     $lang = ICL_LANGUAGE_CODE;
     global $wpdb;
     $querystr = "
        SELECT wposts.*
        FROM $wpdb->posts wposts, wp_icl_translations icl_translations
        WHERE wposts.ID = icl_translations.element_id
        AND icl_translations.language_code = '".$lang."'
        AND wposts.post_status = 'publish'
        AND wposts.post_type = 'restaurant'
    	AND (wposts.post_title LIKE '%$s%'
    	OR   wposts.post_name LIKE '%$s%')
        ";	
     $pageposts = $wpdb->get_results($querystr, OBJECT);
     ?>
    <?php foreach ($pageposts as $key => $value) {
    $resultstr[]  = $value->ID;
    } 
    $result = implode(",",$resultstr);
    echo $result;
    ?>
    			         <?php  echo do_shortcode('[mashup  query="post__in='.$result.'&post_type=restaurant"  mashupBody="address" width="95%"  height="350" alignment="center" directions="none" iwType="ib"]'); ?>
    #13254
    Chris
    Keymaster

    Hi,

    Try removing the do_shortcode() call and see what wp_query would fetch by itself instead – it may just be a query issue:

    <?php 
      $wpq = new WP_Query("post__in=" . $result . "&post_type=restaurant");
      print_r($wpq);
    ?>
    #13255
    bazel
    Participant

    its not the query, I tried like this
    <?php echo do_shortcode('[mashup query="post__in=1454,1460&post_type=restaurant" mashupBody="address" width="95%" height="350" alignment="center" directions="none" iwType="ib"]'); ?>

    1454 and 1460 are post id, type restaurant and this query

    $args = array(
    	'post_type' => 'restaurant',
    	'post__in' => array(1454,1460)
    );
    $wpq = new WP_Query( $args );
     print_r($wpq);
    

    prints the correct array.

    The problem here is that on the search template when we search and nothing is found the map is not showing. If the search returns result then the map is here showing two POIs from the ids 1454,1460

    #13257
    Chris
    Keymaster

    I don’t know if understand the problem – is it that you want to see an empty map when there are no matching posts for the query?

    It would help you if you could email me with a login to your (test) blog along with an example, so I can see it.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.