0

私のマップには投稿の結果が表示されますが、古い投稿のみが表示されます。なぜ新しいものは現れないのですか?私はインドからコーダーを雇いましたが、彼は今隠れています。(私はこのバグを予想していなかったので、私はすでに彼に支払いました.)

マップの下部には、「ジオコード化された広告の総数: 602」と表示されています。これは正しくありません。現在、608 件の投稿が公開されています。では、なぜ新しいものは見つからないのでしょうか?

また、post_date の順に表示されないのはなぜですか?

add_action('wp_ajax_query_total', 'query_total');
add_action('wp_ajax_nopriv_query_total', 'query_total');


if (defined('MULTISITE') && (MULTISITE))
{

    if (!defined('TT'))
        define('TT', plugins_url('/geo-ads/timthumb_wpmu.php'));
}
else
{
    if (!defined('TT'))
        define('TT', plugins_url('/geo-ads/timthumb.php'));
}

function query_total()
{
    global $wpdb;
    $table = $wpdb->prefix.'cp_ad_geocodes';

    $q = "SELECT COUNT(*) FROM $table t LEFT JOIN $wpdb->posts p ON (p.ID = t.post_id) WHERE p.post_status = 'publish'";
    $c = $wpdb->get_var($q);
    echo $c;

    die();

}

function query_geo_ads()
{   
    if ($_GET['range'] == 'true') {
        query_geo_ads_refresh();
    }
    else {
    global $wpdb;   
    $table = $wpdb->prefix.'cp_ad_geocodes';
    $querystr = "SELECT t.post_id, t.category, t.lat, t.lng, p.post_title, p.post_content, m.meta_value as price, CONCAT(wpo_su.option_value, REPLACE( REPLACE( REPLACE( REPLACE(wpo.option_value,'%year%',date_format(p.post_date,'%Y')) ,'%monthnum%',date_format(p.post_date,'%m')) ,'%day%',date_format(p.post_date,'%d')) ,'%postname%',p.post_name ) ) as permalink 
                FROM  $table t LEFT JOIN $wpdb->posts p ON (p.ID = t.post_id)
                INNER JOIN $wpdb->options wpo ON wpo.option_name='permalink_structure'
                INNER JOIN $wpdb->options wpo_su ON wpo_su.option_name='siteurl'
                LEFT JOIN $wpdb->postmeta m ON (m.meta_key = 'cp_price') AND (m.post_id = p.ID)
                WHERE p.post_status = 'publish' 
                    AND p.post_type = 'ad_listing' ";       

    $ads = $wpdb->get_results($querystr);   

    $expires = 50000;
    $cache_time = mktime();

    header("Cache-Control: max-age:" . $expires . ", must-revalidate"); 
    header("Expires: " . gmdate("D, d M Y H:i:s",$cache_time+$expires) . " GMT");

    echo json_encode($ads); 
    die();
    }
}

function get_image_url()
{   $post_id = intval($_POST['id']);
    $attachment = get_posts(array('post_type' => 'attachment','post_status' => 'publish','order' => 'ASC','orderby' => 'post_date','post_mime_type' => 'image','post_parent' => $post_id));
    $height = 100;
    $width = 100;
    $url = TT.'?src='.wp_get_attachment_url($attachment[0]->ID, false).'&h='.$height.'&w='.$width;                      
    if ($attachment)
        echo $url;
    die();
}

function query_geo_ads_refresh() {
?>
<div class="undertab"><span class="big">Classified Ads / <strong><span class="colour">Just Listed</span></strong></span></div>
<?php
    global $wpdb,$wp_query, $post;

    $exclude_categories = $_REQUEST['exclude_categories'];
    $term_id = $_REQUEST['term_id'];
    $term_slug = $_REQUEST['term_slug'];
    $taxonomy_name = $_REQUEST['taxonomy_name'];
    $northeast_lng = $_REQUEST['northeast_lng'];
    $northeast_lat = $_REQUEST['northeast_lat'];
    $southwest_lng = $_REQUEST['southwest_lng'];
    $southwest_lat = $_REQUEST['southwest_lat'];

    if(!empty($exclude_categories)) {
        $exclude_categories = explode(';', $exclude_categories);
    }
    if(!$term_id) // this means root
        //$term_categories = get_terms( 'ad_cat', 'orderby=count&hide_empty=0' );
        $term_categories = get_terms( 'ad_cat', 'order=DESC','orderby=post_date' );
    else {
        $current_term = get_term_by( 'slug', $term_slug, $taxonomy_name );
        $term_categories = get_terms( $taxonomy_name, 'order=DESC','orderby=post_date' );

        if(empty($term_categories))
            $term_categories[] = $current_term;
    }

    foreach ($term_categories as $catinfo_obj)
    {
        $term_id = $catinfo_obj->term_id;
        $arrsrch = array("'");
        $arrrep = array('');
        $name = htmlspecialchars_decode($catinfo_obj->name);
        $name = strtolower(str_replace($arrsrch,$arrrep,$name));
        if(!empty($exclude_categories)) {
            if(in_array(strtolower($name), $exclude_categories))
                continue;
        }
        $subterm_ids = get_term_children( $term_id, 'ad_cat' );
        $subterm_ids[] = $term_id;
        $term_ids = implode(',', $subterm_ids);

        if($term_id)
        {
            $my_post_type = "'ad_listing'";
            $sql = "select * from $wpdb->posts p where p.post_type in ($my_post_type) and p.post_status in ('publish') and p.ID in (select tr.object_id from $wpdb->term_relationships tr join $wpdb->term_taxonomy t on t.term_taxonomy_id=tr.term_taxonomy_id where t.term_id in ($term_ids) )";

            $postinfo = $wpdb->get_results($sql);

            $data_arr = array();
            $geo_codes = array();

            if($postinfo)
            {
                $srcharr = array("'");
                $replarr = array("\'");
                foreach($postinfo as $postinfo_obj)
                {
                    $ID = $postinfo_obj->ID;
                    $title = str_replace($srcharr,$replarr,($postinfo_obj->post_title));
                    $plink = get_permalink($postinfo_obj->ID);

                    $geocode = cp_get_geocode($ID);
                    $lat = $geocode['lat'];
                    $lng = $geocode['lng'];
                    // check current post geo place is within map coord area
                    if($lat > $northeast_lat || $lat < $southwest_lat)
                       continue;
                    if($northeast_lng > $southwest_lng) {
                        if($lng > $northeast_lng || $lng < $southwest_lng)
                            continue;
                    } else {
                        if($lng > 0 && $lng < $southwest_lng)
                            continue;
                        if($lng < 0 && $lng > $northeast_lng)
                            continue;
                    }
                    $address = get_post_meta($ID,'cp_address_line',true);
                    if(!empty($address))
                        $address = str_replace($srcharr,$replarr,(get_post_meta($ID,'cp_address_line',true)));
                    else {
                        $street = get_post_meta($ID,'cp_street',true);
                        $city = get_post_meta($ID,'cp_city',true);
                        $state = get_post_meta($ID,'cp_state',true);
                        $country = get_post_meta($ID,'cp_country',true);
                        if(!empty($street))
                            $address .= $street . ', ';
                        if(!empty($city))
                            $address .= $city . ', ';
                        if(!empty($state))
                            $address .= $state . ', ';
                        if(!empty($country))
                            $address .= $country . ', ';
                        $address = trim($address);
                        $address = substr($address, 0, strlen($address)-1);
                        $address = str_replace($srcharr,$replarr,$address);
                    }

                    $phone = str_replace($srcharr,$replarr,(get_post_meta($ID,'cp_phone',true)));
                    $email = str_replace($srcharr,$replarr,(get_post_meta($ID,'cp_email',true)));
                    $author = get_userdata($postinfo_obj->post_author);
            $category = get_the_category($postinfo_obj->ID);
                    if($postinfo_obj->post_type == 'ad_listing') {
                        $timing = date('M d, Y',strtotime(get_post_meta($ID,'cp_start_date',true))).' to '.date('M d, Y',strtotime(get_post_meta($ID,'cp_end_date',true)));
                    } else {
                        $timing = date('M d, Y',strtotime(get_post_meta($ID,'st_date',true))).' to '.date('M d, Y',strtotime(get_post_meta($ID,'end_date',true))).'<br />'.get_post_meta($ID,'st_time',true).' to '.get_post_meta($ID,'end_time',true);
                    }
                ?>
                    <?php appthemes_before_post(); ?>

        <div class="post-block-out">

            <div class="post-block">

                <div class="post-left">

                    <?php if ( get_option('cp_ad_images') == 'yes' ) cp_ad_loop_thumbnail($ID); ?>

                </div>
                <div class="<?php if ( get_option('cp_ad_images') == 'yes' ) echo 'post-right'; else echo 'post-right-no-img'; ?> <?php echo get_option('cp_ad_right_class'); ?>">

                <!--    <h3><a href="<?php echo $plink; ?>"><?php if ( mb_strlen( $title ) >= 75 ) echo mb_substr( $title, 0, 75 ).'...'; else echo $title; ?></a></h3>

                    <div class="clr"></div>

                    <p class="post-meta">
                    <span class="folder">
                    <a href="/ad-category/<?php echo $catinfo_obj->slug; ?>/">
                    <?php echo $name; ?>
                    </a>
                </span> | 
                <span class="owner">
                    <a href="/author/<?php echo $author->user_nicename; ?>">
                        <?php echo $author->display_name; ?>
                    </a>
                </span> |
                <span class="clock"><span><?php echo $timing; ?></span></span>
                </p>-->


                </div>

                <div class="clr"></div>

            </div><!-- /post-block -->

        </div><!-- /post-block-out -->
     <?php
                }
            }            
        }        
    }

    die();
}
?>

これは index.php ホームページ ファイルです。ホームページは次のように表示されます。

<?php get_header(); ?>

<div class="content_botbg">

    <div class="content_res">
<?php // Comment the default CP Slider
    // if ( file_exists(STYLESHEETPATH . '/featured.php') )
    // include_once(STYLESHEETPATH . '/featured.php');
    // else
    // include_once(TEMPLATEPATH . '/featured.php');
?>



    <!-- left block -->

    <!--<div class="content_left">-->

            <?php if ( get_option('cp_home_layout') == 'directory' ) : ?>

            <div class="shadowblock_out">

                <div class="shadowblock">

                    <h2 class="dotted"><?php _e('Ad Categories','appthemes')?></h2>

                    <div id="directory" class="directory twoCol">


                        <?php echo cp_create_categories_list( 'dir' ); ?>


                        <div class="clr"></div>

                    </div><!--/directory-->

                </div><!-- /shadowblock -->

            </div><!-- /shadowblock_out -->

        <?php endif; ?>


    <div class="tabcontrol">

        <ul class="tabnavig">
          <li><a href="#block1"><span class="big"><?php _e('Just Listed','appthemes')?></span></a></li>
          <li><a href="#block2"><span class="big"><?php _e('Most Popular','appthemes')?></span></a></li>
          <li><a href="#block3"><span class="big"><?php _e('Random','appthemes')?></span></a></li>
        </ul>


    <?php remove_action( 'appthemes_after_endwhile', 'cp_do_pagination' ); ?>
  <?php $post_type_url = get_bloginfo('url').'/'.get_option('cp_post_type_permalink').'/'; ?>

        <!-- tab 1 -->
        <div id="block1">

          <div class="clr"></div>

          <div class="undertab"><span class="big"><?php _e('Classified Ads','appthemes') ?> / <strong><span class="colour"><?php _e('Just Listed','appthemes') ?></span></strong></span></div>

     <?php
                // show all ads but make sure the sticky featured ads don't show up first
                $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
                query_posts( array('post_type' => APP_POST_TYPE, 'ignore_sticky_posts' => 1, 'paged' => $paged) );
        global $wp_query;
        $total_pages = max( 1, absint( $wp_query->max_num_pages ) );
            ?>

            <?php //get_template_part( 'loop', 'ad_listing' ); ?>

    <?php
        if( $total_pages > 1 ){ ?>
        <div class="paging"><a href="<?php echo $post_type_url; ?>page/2/"> <?php _e( 'View More Ads', 'appthemes' ); ?> </a></div>
        <?php } ?>

        </div><!-- /block1 -->



        <!-- tab 2 -->
        <div id="block2">

          <div class="clr"></div>

          <div class="undertab"><span class="big"><?php _e('Classified Ads','appthemes') ?> / <strong><span class="colour"><?php _e('Most Popular','appthemes') ?></span></strong></span></div>

    <?php get_template_part( 'loop', 'featured' ); ?>

    <?php global $cp_has_next_page; ?>
    <?php if($cp_has_next_page){ ?>
        <div class="paging"><a href="<?php echo $post_type_url; ?>page/2/?sort=popular"> <?php _e( 'View More Ads', 'appthemes' ); ?> </a></div>
    <?php } ?>

    <?php wp_reset_query(); ?>

        </div><!-- /block2 -->


        <!-- tab 3 -->
        <div id="block3">

          <div class="clr"></div>

          <div class="undertab"><span class="big"><?php _e('Classified Ads','appthemes') ?> / <strong><span class="colour"><?php _e('Random','appthemes') ?></span></strong></span></div>

            <?php
                // show all random ads but make sure the sticky featured ads don't show up first
                $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
                query_posts( array('post_type' => APP_POST_TYPE, 'ignore_sticky_posts' => 1, 'paged' => $paged, 'orderby' => 'rand') );
        global $wp_query;
        $total_pages = max( 1, absint( $wp_query->max_num_pages ) );
            ?>

            <?php get_template_part( 'loop', 'ad_listing' ); ?>

    <?php
        if( $total_pages > 1 ){ ?>
        <div class="paging"><a href="<?php echo $post_type_url; ?>page/2/?sort=random"> <?php _e( 'View More Ads', 'appthemes' ); ?> </a></div>
        <?php } ?>

        </div><!-- /block3 -->

      </div><!-- /tabcontrol -->




  </div><!-- /content_left -->


        <?php //get_sidebar(); ?>


        <div class="clr"></div>

    </div><!-- /content_res -->

</div><!-- /content_botbg -->

4

0 に答える 0