show author page
-
hi,
currently when i search a book author it will show the books that the author sells. I want this to go to the author page, as it has specific text that i would like the user to see if they search for this author
Is that possible at all? For it to not only show product results but also to show a taxonomy page if it is searched
Thanks,
Adam
-
Hello,
Yes, it is possible. By default you can display categories and tags pages inside search results. If you need to display other taxonomies archive pages than it is possible only with pro plugin version.
Regards
hi thanks for this.
how do i do this, i have the pro plugin and also have selected in archive pages the ‘Book author’ taxonomy but not working
under the view option there is only categories as well.Thanks
Adam-
This reply was modified 4 years, 9 months ago by
onoxin.
So first – you need to activate Taxonomies archives search. Than go to list of all available taxonomies and choose what of them must be available for search – https://prnt.sc/sutd07
Did you follow all this steps?Regards
Yes i have followed these but no luck. https://imgur.com/a/C3T2L8a
-
This reply was modified 4 years, 8 months ago by
onoxin.
I see you enable some taxonomies archive pages for search.
But does you enable taxonomies search itself? https://prnt.sc/sxqb4cHi yes that is enabled too https://imgur.com/a/Sq7C0le
Any idea why it would not be working. I can send you url to site if that helps?
Thanks
AdamYes, this will be great if you send the URL where I can find working search form.
Great thanks the site is setantabooks.com
So, you want to see this Book Authors inside search results page? Previously I think that you are talking about ajax results.
Yes is that possible ILLID?
To show the Book Author page when people search for the book author name – it would be the exact name.Well such feature are not supported by default but you can try to use some code snippet.
You need to add it somewhere outside plugins folder. For example, inside functions.php file of your theme or use some plugin for adding code snippets.add_filter('aws_search_page_results', 'my_aws_search_page_results', 10, 3); function my_aws_search_page_results( $posts, $query, $data ) { $new_posts = array(); $product = get_posts( array( 'posts_per_page' => 1, 'numberposts' => 1, 'fields' => 'ids', 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'suppress_filters' => true, 'no_found_rows' => 1, 'orderby' => 'ID', 'order' => 'ASC', 'lang' => '' ) ); if ( isset( $data['search_res']['s']['tax'] ) && ! empty( $data['search_res']['s']['tax'] ) ) { foreach ( $data['search_res']['s']['tax'] as $tax_name => $tax_terms ) { foreach ( $tax_terms as $tax_term) { $post = new stdClass(); $post->ID = $product[0]; $post->site_id = get_current_blog_id(); $post->post_name = $tax_term['name']; $post->post_title = $tax_term['name']; $post->permalink = $tax_term['link']; $post->post_type = "product"; $post->post_author = "1"; $post->post_status = "publish"; $post->post_parent = 0; $post->post_content = ""; $post->menu_order = 0; $post->post_date = "2000-01-01 12:00:00"; $post->post_date_gmt = "2000-01-01 12:00:00"; $post->post_modified = "2000-01-01 12:00:00"; $post->post_modified_gmt = "2000-01-01 12:00:00"; $post->awssearch = true; if ( $post ) { $new_posts[] = $post; } } } } if ( ! empty( $new_posts ) ) { $posts = $new_posts + $posts; } return $posts; }
Thank you very much for your reply.
Is there anything I need to change in the code? It didn’t work for me.Thanks
-
This reply was modified 4 years, 8 months ago by
onoxin.
Please tell me what WordPress theme you are using?
I am using Storefront ??
Please try to use following code instead
class AWS_Add_Tax { public $tax_id = 0; public $tax = array(); public function __construct() { add_filter( 'aws_search_page_results', array( $this, 'aws_search_page_results' ), 10, 3 ); add_filter( 'woocommerce_loop_product_link', array( $this, 'woocommerce_loop_product_link' ), 10, 2 ); add_filter( 'woocommerce_product_get_image', array( $this, 'woocommerce_product_get_image' ), 10, 4 ); add_filter( 'woocommerce_loop_add_to_cart_link', array( $this, 'woocommerce_loop_add_to_cart_link' ), 10, 2 ); add_filter( 'woocommerce_sale_flash', array( $this, 'woocommerce_sale_flash' ), 10, 3 ); add_filter( 'woocommerce_get_price_html', array( $this, 'woocommerce_get_price_html' ), 10, 2 ); } public function aws_search_page_results( $posts, $query, $data ) { $new_posts = array(); $product = get_posts( array( 'posts_per_page' => 1, 'numberposts' => 1, 'fields' => 'ids', 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'suppress_filters' => true, 'no_found_rows' => 1, 'orderby' => 'ID', 'order' => 'ASC', 'lang' => '' ) ); if ( isset( $data['search_res']['s']['tax'] ) && ! empty( $data['search_res']['s']['tax'] ) ) { $this->tax_id = $product[0]; foreach ( $data['search_res']['s']['tax'] as $tax_name => $tax_terms ) { foreach ( $tax_terms as $tax_term) { $post = new stdClass(); $post->ID = $product[0]; $post->site_id = get_current_blog_id(); $post->post_name = $tax_term['name']; $post->post_title = $tax_term['name']; $post->permalink = $tax_term['link']; $post->post_type = "product"; $post->post_author = "1"; $post->post_status = "publish"; $post->post_parent = 0; $post->post_content = ""; $post->menu_order = 0; $post->post_date = "2000-01-01 12:00:00"; $post->post_date_gmt = "2000-01-01 12:00:00"; $post->post_modified = "2000-01-01 12:00:00"; $post->post_modified_gmt = "2000-01-01 12:00:00"; $post->awssearch = true; if ( $post ) { $new_posts[] = $post; } $this->tax[$post->ID][] = $tax_term; } } } if ( ! empty( $new_posts ) ) { $posts = $new_posts + $posts; } return $posts; } public function woocommerce_loop_product_link( $link, $product ) { $id = $product->get_id(); if ( isset( $_REQUEST['type_aws'] ) && isset( $this->tax[$id] ) ) { foreach( $this->tax[$id] as $key => $tax_term ) { $link = $tax_term['link']; unset( $this->tax[$id][$key] ); break; } return $link; } return $link; } public function woocommerce_product_get_image( $image, $product, $size, $attr ) { $id = $product->get_id(); if ( isset( $_REQUEST['type_aws'] ) && isset( $this->tax[$id] ) ) { return wc_placeholder_img( $size, $attr ); } return $image; } public function woocommerce_loop_add_to_cart_link( $output, $product ) { $id = $product->get_id(); if ( isset( $_REQUEST['type_aws'] ) && isset( $this->tax[$id] ) ) { return ''; } return $output; } public function woocommerce_sale_flash( $output, $post, $product ) { $id = $product->get_id(); if ( isset( $_REQUEST['type_aws'] ) && isset( $this->tax[$id] ) ) { return ''; } return $output; } public function woocommerce_get_price_html( $output, $product ) { $id = $product->get_id(); if ( isset( $_REQUEST['type_aws'] ) && isset( $this->tax[$id] ) ) { return ''; } return $output; } } new AWS_Add_Tax();
-
This reply was modified 4 years, 9 months ago by
- The topic ‘show author page’ is closed to new replies.