- This topic has 21 replies, 4 voices, and was last updated 4 years, 1 month ago by
Tom.
-
AuthorPosts
-
April 25, 2019 at 9:57 am #879427
Cris
Hello,
I need to modify the results page of the searches and taxonomies. How or from where can I modify them?
I have seen that changes can be made from the customizer (in the options of the blog), but this forces me to modify the blog and that is not what I want.April 25, 2019 at 10:15 am #879445Leo
StaffCustomer SupportHi there,
What are you wanting to modify?
Does this help?
https://docs.generatepress.com/article/option_generate_blog_settings/
https://docs.generatepress.com/article/option_generate_blog_settings/#examplesLet me know 🙂
April 25, 2019 at 1:13 pm #879633Cris
Thanks Leo, that helps me for the search results. For the results of the taxonomies, it does not work. How can I modify them? I would like to use “WP Show Posts Pro” to applicate here.
April 25, 2019 at 4:03 pm #879743Tom
Lead DeveloperLead DeveloperThose options won’t work with WP Show Posts, as it’s a different plugin altogether.
If you’re using the theme to output the taxonomy archives, you should just be able to duplicate your search results code and use
is_tax()
instead ofis_search()
.April 25, 2019 at 10:59 pm #879950Cris
I do not know if it is possible to put the image, smaller, next to the title. Because the images of the taxonomies are very small and of poor quality.
I do that but doesn’t work. Report this error:
Cannot redeclare lh_custom_search_results_page_settings() (previously declared in wp-content/themes/generatepress_child/functions.php:18)The code is:
add_filter( 'option_generate_blog_settings', 'lh_custom_search_results_page_settings' ); function lh_custom_search_results_page_settings( $options ) { if ( is_tax() ) { $options['read_more_button'] = true; $options['date'] = false; $options['categories'] = false; $options['tags'] = false; $options['comments'] = false; $options['infinite_scroll'] = true; $options['infinite_scroll_button'] = true; $options['masonry_load_more'] = 'Ver más resultados'; $options['masonry_loading'] = 'Cargando más resultados'; $options['post_image'] = true; $options['post_image_position'] = 'post-image-above-header'; $options['post_image_alignment'] = 'post-image-aligned-center'; $options['column_layout'] = false; $options['featured_column'] = false; $options['masonry'] = false; } return $options; }
April 26, 2019 at 9:11 am #880628Tom
Lead DeveloperLead DeveloperYou need to change the function name to something else.
For example, replace
lh_custom_search_results_page_settings
withlh_custom_taxonomy_page_settings
It needs to be changed in the function name and in the
add_filter
function.April 26, 2019 at 9:40 am #880671Cris
Works, thanks!
April 26, 2019 at 5:51 pm #881013Tom
Lead DeveloperLead DeveloperYou’re welcome 🙂
May 1, 2019 at 6:25 am #885473Michael
Hi i have the same question, i want to change the default search page. and i read the document on
https://docs.generatepress.com/article/option_generate_blog_settings/#examplesbut where can i put the code on?
this code:
add_filter( ‘option_generate_blog_settings’, ‘lh_custom_search_results_page_settings’ );
function lh_custom_search_results_page_settings( $options ) {
if ( is_search() ) {
$options[‘read_more_button’] = true;
$options[‘date’] = false;
$options[‘categories’] = false;
$options[‘tags’] = false;
$options[‘comments’] = false;
$options[‘infinite_scroll’] = true;
$options[‘infinite_scroll_button’] = true;
$options[‘masonry_load_more’] = ‘More search results’;
$options[‘post_image’] = true;
$options[‘post_image_position’] = ‘post-image-above-header’;
$options[‘post_image_alignment’] = ‘post-image-aligned-center’;
$options[‘column_layout’] = false;
$options[‘featured_column’] = true;
$options[‘masonry’] = false;
}return $options;
}thank you
May 1, 2019 at 11:11 am #885838Cris
Hi
Tom, I think that something is wrong with taxonomy page because the code doesn’t work well. See here please. In search result work well, masonry, column, etc. In taxonomy only work post_image_alignment. Why?
Michael, to add code read this instructions: https://docs.generatepress.com/article/adding-php/
May 1, 2019 at 2:50 pm #885957Tom
Lead DeveloperLead DeveloperCan you show me your full code?
May 1, 2019 at 6:44 pm #886043Michael
THanks cris
May 1, 2019 at 10:48 pm #886154Cris
I have this in function.php
<?php
/**
* GeneratePress child theme functions and definitions.
*
* Add your custom PHP in this file.
* Only edit this file if you have direct access to it on your server (to fix errors if they happen).
*/function generatepress_child_enqueue_scripts() {
if ( is_rtl() ) {
wp_enqueue_style( ‘generatepress-rtl’, trailingslashit( get_template_directory_uri() ) . ‘rtl.css’ );
}
}
add_action( ‘wp_enqueue_scripts’, ‘generatepress_child_enqueue_scripts’, 100 );/*Resultados búsquedas*/
add_filter( ‘option_generate_blog_settings’, ‘lh_custom_search_results_page_settings’ );
function lh_custom_search_results_page_settings( $options ) {
if ( is_search() ) {
$options[‘read_more_button’] = true;
$options[‘date’] = false;
$options[‘categories’] = false;
$options[‘tags’] = false;
$options[‘comments’] = false;
$options[‘infinite_scroll’] = true;
$options[‘infinite_scroll_button’] = true;
$options[‘masonry_load_more’] = ‘Ver más resultados’;
$options[‘masonry_loading’] = ‘Cargando más resultados’;
$options[‘post_image’] = true;
$options[‘post_image_position’] = ‘post-image-above-header’;
$options[‘post_image_alignment’] = ‘post-image-aligned-center’;
$options[‘column_layout’] = false;
$options[‘featured_column’] = false;
$options[‘masonry’] = false;
}return $options;
}/*Resultados taxonomÃas*/
add_filter( ‘option_generate_blog_settings’, ‘lh_custom_taxonomy_page_settings’ );
function lh_custom_taxonomy_page_settings( $options ) {
if ( is_tax() ) {
$options[‘read_more_button’] = false;
$options[‘infinite_scroll’] = true;
$options[‘infinite_scroll_button’] = true;
$options[‘masonry_load_more’] = ‘Ver más resultados’;
$options[‘masonry_loading’] = ‘Cargando más resultados’;
$options[‘post_image’] = true;
$options[‘post_image_position’] = ‘post-image-above-header’;
$options[‘post_image_alignment’] = ‘post-image-aligned-left’;
$options[‘column_layout’] = false;
$options[‘featured_column’] = false;
$options[‘masonry’] = false;
}return $options;
}/*Buscar solo en post*/
function buscador_mostrar_solo_posts($query)
{
if ($query->is_search)
{
$query->set(‘post_type’, ‘post’);
}
return $query;
}
add_filter(‘pre_get_posts’, ‘buscador_mostrar_solo_posts’);May 2, 2019 at 8:18 am #886783Tom
Lead DeveloperLead DeveloperYour code looks ok, but I can’t see the page as it’s behind a coming soon page.
May 2, 2019 at 8:24 am #886787Cris
Sorry, Try now.
-
AuthorPosts
- You must be logged in to reply to this topic.