Some Question
-
1. Can I create two search forms?
I don’t mean to put the search form in 2 places, but I want to make 2 searches with different settings.
2. Can I put the search form on the category and tag pages? And the search form in categories and tags page only searching for articles in that taxonomy.
Can it?- This topic was modified 3 years ago by Mushlih Almubarak.
- This topic was modified 3 years ago by Mushlih Almubarak.
-
Hi,
1. Unfortunately multiple search forms with different configurations are only available in the Pro version of the plugin.
2. There is no option, but you can try this custom code:
add_action('asl_layout_in_form', 'asl_layout_in_form_archive_input', 10); function asl_layout_in_form_archive_input() { $taxonomies = 'category, post_tag, product_cat'; // Enter the taxonomy names here // --- DO NOT CHANGE ANYTHING BELOW THIS LINE --- $taxonomies = explode(',', $taxonomies); foreach ( $taxonomies as $k => &$tax ) $tax = trim($tax); if ( ( in_array('category', $taxonomies) && is_category() ) || ( in_array('post_tag', $taxonomies) && is_tag() ) || is_tax($taxonomies) ) { $obj = get_queried_object(); if ( isset($obj, $obj->term_id) ) { ?> <input type="hidden" styl="display:none;" name="asl_tax_archive" value="<?php echo $obj->term_id; ?>"> <?php } } } // --- DO NOT CHANGE ANYTHING BELOW HERE EITHER --- add_filter( 'asl_query_args', 'asl_archive_page_category_restriction', 10, 1 ); function asl_archive_page_category_restriction($args) { if ( isset($_POST, $_POST['options']) ) { parse_str($_POST['options'], $so); if ( !empty($so['asl_tax_archive']) ) { $term = get_term($so['asl_tax_archive']); if ( !is_wp_error($term) ) { $args['post_tax_filter'][] = array( 'taxonomy' => $term->taxonomy, 'include' => array($term->term_id), 'exclude' => array(), 'logic' => 'AND', 'allow_empty' => false ); } } } return $args; }
It’s a stretch, but it may actually work.
Best,
Ernest M.Ok, thank you
Hi, sorry, that didn’t work
I’ve put the code in my theme’s PHP functions, but not a single search form appears on the taxonomies page
I have also changed thecategory
to my category name but it still doesn’t work
I use this themeHi!
That code is to restrict the searches to the single taxonomy archive page items, it does not put the search there.
You may have to use the theme editor, or put a search widget there.Best,
Ernest M.You may have to use the theme editor, or put a search widget there.
What search widget should I put? Should it be from your plugin? Or can it be from another plugin?
What search widget should I put? Should it be from your plugin? Or can it be from another plugin?
Well, if you want to display the search bar from this plugin then the one from this plugin.
So I just put your plugin shortcode on the category page and it will search for articles only on that taxonomy?
No, you also need the custom code I suggested above. That adds a special parameter to the search form to try to restrict to current archive page only. It is still not guaranteed to work, but it is worth try.
Best,
Ernest M.Unfortunately, the code still doesn’t work, here’s what I’ve done:
1. I changed this code:
add_action('asl_layout_in_form', 'asl_layout_in_form_archive_input', 10); function asl_layout_in_form_archive_input() { $taxonomies = 'category, post_tag, product_cat'; // Enter the taxonomy names here
Becomes:
add_action('asl_layout_in_form', 'asl_layout_in_form_archive_input', 10); function asl_layout_in_form_archive_input() { $taxonomies = 'akidah'; // Enter the taxonomy names here
2. I put the code into my child’s theme function.php
3. I created a template for archive pages using Elementor.
4. I add a list of articles from a category to the page using the “archive posts” widget from Elementor Pro.
5. I added a search form using your plugin on the archive page.
6. I update the page and exit from the page editor, then I test the search form, and I find the search form is still searching for everything on my site, not just articles in that category.
is there something wrong?
Thank you- This reply was modified 2 years, 12 months ago by Mushlih Almubarak.
Thanks for the details, it is very hard to tell. Can you please share a link, where I can check this?
I’m sorry, but it’s a local site.
Do you want me to provide the JSON file of the elementor template I created? Along with the Elementor pro plugin file?Thank you, but I’m afraid that is not going to help in this case.
Best,
Ernest M.It’s weird, I just uploaded the site to the staging site (live) to show it to you, but when I tried the code it worked fine, even though the settings on my staging site and my local site were the same.
Does the code only work if the site is live?It should not make any difference whatsoever from the code perspective. Something else may work differently on a live server, which could affect this code, but I honestly have no idea what it could be.
All right, thank you very much for the help and code
I will tell you about the code if there is a problem when I have uploaded the local site to hosting
Thank you
- The topic ‘Some Question’ is closed to new replies.