• Hi
    plz
    I want to change the code

    <div class="properties-filter-sort-by-wrapper">
    				<select class="form-control" name="filter-sort-by">
    					<option value=""><?php echo __( 'Sort by', 'realia' ); ?></option>
    					<option value="price" <?php if ( ! empty( $_GET['filter-sort-by'] ) && 'price' == $_GET['filter-sort-by'] ) :   ?>selected="selected"<?php endif; ?>><?php echo __( 'Price', 'realia' ); ?></option>
    					<option value="title" <?php if ( ! empty( $_GET['filter-sort-by'] ) && 'title' == $_GET['filter-sort-by'] ) :   ?>selected="selected"<?php endif; ?>><?php echo __( 'Title', 'realia' ); ?></option>
    					<option value="published" <?php if ( ! empty( $_GET['filter-sort-by'] ) && 'published' == $_GET['filter-sort-by'] ) :   ?>selected="selected"<?php endif; ?>><?php echo __( 'Published', 'realia' ); ?></option>
    				</select>
    			</div><!-- /.filter-sort-by-wrapper -->

    And replace by defalut to random and if possible to hide (Sorting options and Order)

    tanks to all

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You can hide the sorting options with CSS

    .properties-filter-sort-by-wrapper {
       display: none;
    }

    To achieve random order, assuming the listing is achieved with the WP_Query class, use the “pre_get_posts” action. What ever you do in this action will affect all post queries, so you either should conditionally add your callback only when needed or place a conditional within the callback so the random ordering is only applied to queries where it is wanted.

    Aside from the conditionals, set the ‘orderby‘ query var to ‘rand’.

Viewing 1 replies (of 1 total)

The topic ‘change code to random sort’ is closed to new replies.