vivekse2m
Forum Replies Created
-
Hi,
I have yet another query, to which I need a real quick response.
I have implemented a “Near Me” sorting query in the custom post type archive page, with which I am not getting the custom post array(with their respective post ids) as sort results.
Now I cannot find a way to set that array of sort results as the main array of data for the repeater template (as repeater template works with posts coming from database directly).
Also let me tell you, I have other sorting types also active in that same repeater template page, which I don’t want affected by the “sorting with location near me”.
Can you assist ?
Awaiting your response…
Regards,
Vivek Shah- This reply was modified 7 years, 6 months ago by vivekse2m.
Ok, but can you show me with an example relative to my code I have posted, can you show me a demo for the same ?
Please check below, it is my custom repeater template that I have set in the site for Load More functionality.
I think you will get idea, what am I trying to do here.
<?php error_reporting(E_ALL & ~E_NOTICE); global $wp_query,$shortcode_tags; //$post = $wp_query->post; if(!$_SESSION['location_near_sort_arr']): $post = get_posts(); $post_id = $post->ID; $postMeta = get_post_meta( $post_id ); $practSpecData = get_post_custom( $post_id ); array_walk($practSpecData, function(&$value, $key) { $value = array_shift( $value ); }); $practSpecData = array_filter($practSpecData, function(&$value, $key) { if (startsWith($key, '_')) unset($key, $value); else return $key; }, ARRAY_FILTER_USE_BOTH); $practSpecData = array_filter($practSpecData, function(&$value, $key) { if (startsWith($key, 'eg_')) unset($key, $value); else return $key; }, ARRAY_FILTER_USE_BOTH); $practAddLocs = unserialize($practSpecData['additional_locations']); $practAddLocsCnt = count($practAddLocs); ?> <div class='location_list providers_list'> <div class="clearfix"> <div class="location_img"> <img src="<?php echo wp_get_attachment_url( $post_id ); ?>" class="img-responsive" /> </div> <div class="location_content"> <div class='location_list_content'> <h3><?php echo $practSpecData['firstname'] . " " . $practSpecData['lastname']; ?>, <?php echo $practSpecData['credential'] ?></h3> <p><?php echo $practSpecData['short_biography'] ?></p> <h5>Locations</h5> <p id="pract<?php echo $post_id; ?>"> <span> <?php echo get_location_name_byid($practSpecData['primary_location']); //if($practAddLocsCnt > 0) echo ','; ?> </span> <?php if(!empty($practSpecData['additional_locations'])): ?> <?php $i = 0; foreach($practAddLocs as $addlocation) { $addlocation = get_location_name_byid( $addlocation ); if( $i < $practAddLocsCnt-1 ): echo "<span class=\"addlocshow\">,{$addlocation}</span>"; else: echo "<span class=\"addlocshow\">{$addlocation}</span>"; endif; } ?> <?php if($practAddLocsCnt > 3): echo '<a class="underline" href="javascript:;">(2 more)</a>'; echo '<a class="underline-less" style="display:none;" href="javascript:;">(2 less)</a>'; endif; ?> <?php endif; ?> <script type="text/javascript"> $(function() { var $divHead = $('p#pract<?php echo $post_id ?>'); $divHead.find('span.addlocshow').slice(-2).hide(); $divHead.find('a.underline').click(function() { $divHead.find('span.addlocshow').slice(-2).show(); $(this).hide(); $divHead.find('a.underline-less').show(); }); $divHead.find('a.underline-less').click(function() { $divHead.find('span.addlocshow').slice(-2).hide(); $(this).hide(); $divHead.find('a.underline').show(); }); }); </script> </p> <a href="<?php echo get_permalink($post_id) ?>" class="learn_more">Full Profile</a> </div> </div> </div> </div> <?php else: ?> <?php foreach($_SESSION['location_near_sort_arr'] as $post_id => $value): $postMeta = get_post_meta( $post_id ); $practSpecData = get_post_custom( $post_id ); array_walk($practSpecData, function(&$value, $key) { $value = array_shift( $value ); }); $practSpecData = array_filter($practSpecData, function(&$value, $key) { if (startsWith($key, '_')) unset($key, $value); else return $key; }, ARRAY_FILTER_USE_BOTH); $practSpecData = array_filter($practSpecData, function(&$value, $key) { if (startsWith($key, 'eg_')) unset($key, $value); else return $key; }, ARRAY_FILTER_USE_BOTH); $practAddLocs = unserialize($practSpecData['additional_locations']); $practAddLocsCnt = count($practAddLocs); ?> <div class='location_list providers_list'> <div class="clearfix"> <div class="location_img"> <img src="<?php echo wp_get_attachment_url( $post_id ); ?>" class="img-responsive" /> </div> <div class="location_content"> <div class='location_list_content'> <h3><?php echo $practSpecData['firstname'] . " " . $practSpecData['lastname']; ?>, <?php echo $practSpecData['credential'] ?></h3> <p><?php echo $practSpecData['short_biography'] ?></p> <h5>Locations</h5> <p id="pract<?php echo $post_id; ?>"> <span> <?php echo get_location_name_byid($practSpecData['primary_location']); //if($practAddLocsCnt > 0) echo ','; ?> </span> <?php if(!empty($practSpecData['additional_locations'])): ?> <?php $i = 0; foreach($practAddLocs as $addlocation) { $addlocation = get_location_name_byid( $addlocation ); if( $i < $practAddLocsCnt-1 ): echo "<span class=\"addlocshow\">,{$addlocation}</span>"; else: echo "<span class=\"addlocshow\">{$addlocation}</span>"; endif; } ?> <?php if($practAddLocsCnt > 3): echo '<a class="underline" href="javascript:;">(2 more)</a>'; echo '<a class="underline-less" style="display:none;" href="javascript:;">(2 less)</a>'; endif; ?> <?php endif; ?> <script type="text/javascript"> $(function() { var $divHead = $('p#pract<?php echo $post_id ?>'); $divHead.find('span.addlocshow').slice(-2).hide(); $divHead.find('a.underline').click(function() { $divHead.find('span.addlocshow').slice(-2).show(); $(this).hide(); $divHead.find('a.underline-less').show(); }); $divHead.find('a.underline-less').click(function() { $divHead.find('span.addlocshow').slice(-2).hide(); $(this).hide(); $divHead.find('a.underline').show(); }); }); </script> </p> <a href="<?php echo get_permalink($post_id) ?>" class="learn_more">Full Profile</a> </div> </div> </div> </div> <?php endforeach; ?> <?php endif; ?>
I am trying to do customized sorting for “near me” locations, and as those type of sorting cannot be done by database, I am taking the help of array sorting, but when I do that I am getting same slot of records over and over again when I click on “More” button.
Can you help out, it’s really urgent….
Regards,
Vivek ShahHi, dcooney, are you online ?
I have another query regarding this same topic, can I ask and expect earliest reply from you ?
Regards,
Vivek ShahOk thanks, how can I pass custom (non-preset) arguments and access those arguments inside shortcode expansion ?