How to” with FacetWP

As you’ve gone for Adding an Advanced Fil­ter­ing Sys­tem with FacetWP, then you prob­a­bly fig­ured out how to play with it, adding new facets and more. With that being said, here are a cou­ple of exam­ples which can be used under Set­tings → FacetWP → Tem­plates in the List­ings tem­plate:

How to sort them alphabetically:

<?php
return array(
  "post_type" => "job_listing",
  "post_status" => "publish",
  "orderby" => "title",
  "order" => "ASC",
  "posts_per_page" => 50
);
<?php
return array(
 "post_type" => "job_listing",
 "post_status" => "publish",
 'meta_key'   => '_featured',
 "orderby" => array( 'meta_value_num' => 'DESC', 'title' => 'ASC' ),
 "posts_per_page" => 50,
);

How to show different number of listings per page depending on screen size:

<?php
if ( wp_is_mobile() ) {
  return array(
      'post_type' => 'any',
      'post_status' => 'publish',
      'posts_per_page' => 10,
  );
}else{
  return array(
      'post_type' => 'any',
      'post_status' => 'publish',
      'posts_per_page' => 16,
  );
}

Of course, you can have more sort­ing meth­ods by using FaceWP’s Query builder or by check­ing out the Word­Press Query Argu­ments.

Updated on May 30, 2017

Was this article helpful?

Related Articles