-
AuthorPosts
-
March 26, 2019 at 3:52 pm #1083140
Hi
I tried to modify the Enfold file template-archives.php in order to create my custom search filter form for the frontend based on that. “That” means advanced post type in my case which is already created, all the data (including attached advanced custom fields) is already visible in the backend.
The goal now is to create a custom filter/search for the frontend based on this data. So as already mentioned I modified the php file above, however, I receive a white screen in the frontend afterwards (and I have no clue why that happens). This is the code I have added to template-archives.php:
/* Custom variables for filter */ if($_GET['region'] && !empty($_GET['region'])) { $region = $_GET['region']; } if($_GET['country'] && !empty($_GET['country'])) { $country = $_GET['country']; }
And also:
<form action="<?php the_permalink(); ?>" method="get"> <label>Nachname</label> <input type="text" id="nachname" name="form[nachname]"> <label>Vorname</label> <input type="text" id="vorname" name="form[vorname]"> <label>PLZ</label> <input type="number" name="plz"> <label>Ort</label> <input type="text" id="ort" name="form[ort]"> <label>Region</label> <select name="region"> <option value="tal">Tal</option> <option value="berg">Berg</option> </select> <label>Land</label> <select name="country"> <option value="GER">Deutschland</option> <option value="AUT">Österreich</option> <option value="ITA">Italien</option> </select> <label>Zertifikate</label> <label><input type="checkbox" name="form[diplom1][]" value="diplomdate">Diplom 1</label> <label><input type="checkbox" name="form[diplom2][]" value="branchdiplomdate">Diplom 2</label> <button type="submit" name="">Suchen</button> </form> <?php // Define arguments $args = array( 'post_type' => 'post', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => 'nachname', 'type' => 'CHAR', 'value' => '', 'compare' => 'LIKE' ), array( 'key' => 'vorname', 'type' => 'CHAR', 'value' => '', 'compare' => 'LIKE' ), array( 'key' => 'plz', 'type' => 'NUMERIC', 'value' => '', 'compare' => 'LIKE' ), array( 'key' => 'ort', 'type' => 'CHAR', 'value' => '', 'compare' => 'LIKE' ), array( 'key' => 'region', 'type' => 'CHAR', 'value' => $region, 'compare' => 'LIKE' ), array( 'key' => 'country', 'type' => 'CHAR', 'value' => $country, 'compare' => 'LIKE' ), array( 'key' => 'diplom1', 'type' => 'CHAR', 'value' => $form[diplom1][], 'compare' => 'LIKE' ), array( 'key' => 'diplom2', 'type' => 'CHAR', 'value' => $form[diplom2][], 'compare' => 'LIKE' ) ) ); $query = new WP_Query($args); while($query -> have_posts()) : $query -> the_post(); endwhile; wp_reset_query(); ?>
It would be great if anybody knows what I am doing wrong and could help me here – thanks in advance.
MichaelApril 1, 2019 at 4:44 pm #1085576Hey Michael,
Could you please create a staging site and post FTP and WP admin logins here privately so we can look into it?
Best regards,
YigitApril 1, 2019 at 4:51 pm #1085578Hey Yigit
Thanks for your answer.
I actually found a really good plugin which helped me to solve my issues nicely.You can close this thread.
Thanks
MichaelApril 1, 2019 at 5:53 pm #1085592Hi,
I’m glad this was resolved. If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon -
AuthorPosts
- The topic ‘Custom template archive page with custom field filter’ is closed to new replies.