Geo my word press sort a-z

Hi everyone, I’ve been scratching my head trying to figure out how to sort my geo my wp custom posts when searching by the address, I want to put it alphabetically (post ID) out where to put this code

I’ve created a new file in the search results folder called functions.php and also gone into the content file but I’m having no look. can anyone advise what I’m doing wrong?

Thanks Matthew

"function gmw_sort_alphabetically( $args, $gmw ) {

//replace the value 1 with the form ID that you want to sort
if ( $gmw['ID'] == 2 ) {
	$args['orderby'] = 'post_title';
	$args['order']	 = 'ASC';
}

return $args;

}
add_filter( ‘gmw_pt_search_query_args’, ‘gmw_sort_alphabetically’, 50, 2 );

here is also my content file

"

`<?php
/**

  • Posts locator “grid-gray” search results template file.
  • This file outputs the search results.
  • You can modify this file to apply custom changes. However, it is not recomended
  • to make the changes directly in this file,
  • because your changes will be overwritten with the next update of the plugin.
  • Instead you can copy-paste this template ( the “gray” folder contains this file
  • and the “css” folder ) into the theme’s or child theme’s folder of your site,
  • and apply your changes from there.
  • The custom template folder will need to be placed under:
  • your-theme’s-or-child-theme’s-folder/geo-my-wp/posts-locator/search-results/
  • Once the template folder is in the theme’s folder, you will be able to select
  • it in the form editor. It will show in the “Search results” dropdown menu labed with "Custom: ".
  • @param $gmw ( array ) the form being used
  • @param $gmw_form ( object ) the form object
  • @param $post ( object ) post object in the loop
  • @package geo-my-wp
    */

?>

<?php if ( $gmw_form->has_locations() ) : ?>

	<div class="gmw-results">

		<?php do_action( 'gmw_search_results_start', $gmw ); ?>
		<div class="gmw-results-message">
			<span><?php gmw_results_message( $gmw ); ?></span>
			<?php do_action( 'gmw_search_results_after_results_message', $gmw ); ?>
		</div>

		<?php do_action( 'gmw_search_results_before_top_pagination', $gmw ); ?>

		<div class="pagination-per-page-wrapper top" >
			<?php gmw_per_page( $gmw ); ?>
			<?php gmw_pagination( $gmw ); ?>
		</div> 

		<?php gmw_results_map( $gmw ); ?>

		<?php do_action( 'gmw_search_results_before_loop', $gmw ); ?>
	<div id="dina_course_filter" style="margin-top: 20px;" >
		<div class="ecs-posts elementor-posts-container elementor-posts   elementor-grid elementor-posts--skin-archive_custom facetwp-template">

			<?php
			while ( $gmw_query->have_posts() ) :
				$gmw_query->the_post();
				?>

				<?php global $post; ?>
<?php if(has_post_thumbnail()){ the_post_thumbnail(); }else{ ?> <?php }?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="elementor-column elementor-col-50 elementor-top-column elementor-element elementor-element-5b1b077" data-id="5b1b077" data-element_type="column">
                        <div class="elementor-column-wrap elementor-element-populated">
                            <div class="elementor-widget-wrap">
                                <div class="elementor-element elementor-element-f516154 elementor-widget elementor-widget-theme-post-title elementor-page-title elementor-widget-heading" data-id="f516154" data-element_type="widget" data-widget_type="theme-post-title.default">
                                    <div class="elementor-widget-container">
                                        <h3 class="elementor-heading-title elementor-size-default"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                                    </div>
                                </div>
                                <div class="elementor-element elementor-element-0169883 elementor-icon-list--layout-traditional elementor-list-item-link-full_width elementor-widget elementor-widget-icon-list" data-id="0169883" data-element_type="widget" data-widget_type="icon-list.default">
                                    <div class="elementor-widget-container">
                                        <ul class="elementor-icon-list-items">
                                            <li class="elementor-icon-list-item">
                                                <span class="elementor-icon-list-text"><b> Club Name: </b><?php echo get_field('club_name') ?></span>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                                <div class="elementor-element elementor-element-aad294b elementor-widget elementor-widget-shortcode" data-id="aad294b" data-element_type="widget" data-widget_type="shortcode.default">
                                    <div class="elementor-widget-container">
                                        <div class="elementor-shortcode">
                                            <?php echo do_shortcode('[site_reviews_summary assigned_posts="'.get_the_ID().'" hide="bars,rating"]'); ?>
                                        </div>
                                    </div>
                                </div>
                                <div class="elementor-element elementor-element-d98d852 elementor-widget elementor-widget-shortcode" data-id="d98d852" data-element_type="widget" data-widget_type="shortcode.default">
                                    <div class="elementor-widget-container" style="margin: 10px 0;">
                                        <?php 
										$morelink = ' <a href=".the_permalink().">Know More</a>';
										echo wp_trim_words( get_the_content(), 12, $morelink); ?>
                                    </div>
                                </div>
                                <div class="elementor-element elementor-element-73c8d90 elementor-widget__width-auto elementor-widget elementor-widget-heading" data-id="73c8d90" data-element_type="widget" data-widget_type="heading.default">
                                    <div class="elementor-widget-container">
                                        <span class="elementor-heading-title elementor-size-default">Starting From £ <?php echo get_field('weekday_price'); ?></span>
                                    </div>
                                </div>
                                <div class="elementor-element elementor-element-4d45c5f elementor-widget__width-auto elementor-widget elementor-widget-heading" data-id="4d45c5f" data-element_type="widget" data-widget_type="heading.default">
                                    <div class="elementor-widget-container">
                                        <span class="elementor-heading-title elementor-size-default">Type: <?php echo get_field('course_type'); ?></span>
                                    </div>
                                </div>
                                <div class="elementor-element elementor-element-784105d elementor-widget__width-auto elementor-widget elementor-widget-heading" data-id="784105d" data-element_type="widget" data-widget_type="heading.default">
                                    <div class="elementor-widget-container">
                                        <span class="elementor-heading-title elementor-size-default">Architect: <?php echo get_field('course_architect'); ?></span>
                                    </div>
                                </div>
                                <div class="elementor-element elementor-element-44e97ca elementor-widget elementor-widget-spacer" data-id="44e97ca" data-element_type="widget" data-widget_type="spacer.default">
                                    <div class="elementor-widget-container">
                                        <div class="elementor-spacer">
                                            <div class="elementor-spacer-inner"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
</div>
			<?php endwhile; ?>
		</div>
	</div>

		<?php do_action( 'gmw_search_results_after_loop', $gmw ); ?>

		<div class="pagination-per-page-wrapper bottom">
			<?php gmw_per_page( $gmw ); ?>
			<?php gmw_pagination( $gmw ); ?>
		</div> 

		<?php do_action( 'gmw_search_results_end', $gmw ); ?>

	</div>

<?php else : ?>

	<div class="gmw-no-results">
		<?php do_action( 'gmw_no_results_start', $gmw ); ?>

		<?php gmw_no_results_message( $gmw ); ?>

		<?php do_action( 'gmw_no_results_end', $gmw ); ?> 
	</div>

<?php endif; ?>
`
Sponsor our Newsletter | Privacy Policy | Terms of Service