[Resolved] Custom result page and taxonomy

Home Forums Support [Resolved] Custom result page and taxonomy

Home Forums Support Custom result page and taxonomy

Viewing 15 posts - 1 through 15 (of 22 total)
  • Author
    Posts
  • #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.

    GeneratePress 2.2.2
    GP Premium 1.8.1
    #879445
    Leo
    Staff
    Customer Support
    #879633
    Cris

    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.

    #879743
    Tom
    Lead Developer
    Lead Developer

    Those 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 of is_search().

    #879950
    Cris

    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;
    }
    #880628
    Tom
    Lead Developer
    Lead Developer

    You need to change the function name to something else.

    For example, replace lh_custom_search_results_page_settings with lh_custom_taxonomy_page_settings

    It needs to be changed in the function name and in the add_filter function.

    #880671
    Cris

    Works, thanks!

    #881013
    Tom
    Lead Developer
    Lead Developer
    #885473
    Michael

    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/#examples

    but 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

    #885838
    Cris

    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/

    #885957
    Tom
    Lead Developer
    Lead Developer

    Can you show me your full code?

    #886043
    Michael

    THanks cris

    #886154
    Cris

    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’);

    #886783
    Tom
    Lead Developer
    Lead Developer

    Your code looks ok, but I can’t see the page as it’s behind a coming soon page.

    #886787
    Cris

    Sorry, Try now.

Viewing 15 posts - 1 through 15 (of 22 total)
  • You must be logged in to reply to this topic.