Support Forum

Please login to receive premium support.

Support for the free plugin can be found here.

Forum Replies Created

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • in reply to: WPSP Image elements explicit width and height CSS advice #34984
    Nicolas
    Participant

    Hello,

    Just a thought, with the following code I seem to be able to get rid of the explicit height/width PageSpeed insights warning:

     .wp-show-posts-image img {
        object-fit: cover;
        height: 300px;
        width: 450px;
    }

    But it seems to be at the expense of the CLS score. I don’t know if it really is the way to go.

    in reply to: Using WPSP with Search and Filter Pro #34615
    Nicolas
    Participant

    Thank you Elvin,

    I didn’t have to touch anything in wp-show-posts.php.

    Your new snippet works well for the regular search page. Here is for example the results for the word “huissiers”, WPSP is used correctly to display the results: http://hautlescours.fr.dedivirt248.your-server.de/?s=huissiers

    Unfortunately such is not the case when I search/filter results through Search and Filter Pro (here on the same search “huissiers”): http://hautlescours.fr.dedivirt248.your-server.de/?sfid=32129&_sf_s=huissiers

    But I think I’d rather ask Search and Filter Pro support for help as the bulk of the functionality I want is on their side.

    Best.

    in reply to: Using WPSP with Search and Filter Pro #34565
    Nicolas
    Participant

    Hello, this is the snippet:

    add_action( 'generate_before_main_content', function() {
        if ( is_search() ) {
            wpsp_display( 78685 );
        }
    } );
    
    add_filter( 'wpsp_query_args', function( $query, $settings ) {
        if ( 78685 === (int) $settings['list_id'] ) {
            $query->set( 's', esc_html( $_GET['s'] ) );
        }
    
        return $query;
    } );
    
    add_filter( 'generate_has_default_loop', function( $has_loop ) {
        if ( is_search() ) {
            return false;
        }
    
        return $has_loop;
    } );
    in reply to: Using WPSP with Search and Filter Pro #34509
    Nicolas
    Participant

    Thank you Elvin,

    I installed WPSP 1.2.0-alpha.3 along with WPSP Pro 1.0.0 and added Tom’s snippet to my functions.php file but unfortunately the snippet breaks my site: http://hautlescours.fr.dedivirt248.your-server.de/?s=test

    Best,

    Nicolas

    in reply to: Use WP Show Posts to Replace Blog Archive Page #32548
    Nicolas
    Participant

    Thank you very much Elvin, I think you nailed it!

    Using get_queried_object() seems to be the way to go to use WPSP to display the archive page of a custom taxonomy.

    Thanks for your patience.

    in reply to: Use WP Show Posts to Replace Blog Archive Page #32507
    Nicolas
    Participant

    Thank you Elvin but we are back at the situation of reply 32434.

    Here is what happens:

    • If the first post of the archive page has only one term for the taxonomy ‘lieu’ (the slug of the archive page, for example paris-05) there is no problem. For example https://hautlescours.fr/racinetest10/lieu/paris-05/, WPSP and the theme archive module give the same result
    • If the first post of the archive has several terms for the taxonomy ‘lieu’ but that the term of the archive page is the last term of the post for this taxonomy, it also works: for example https://hautlescours.fr/racinetest10/lieu/paris-07/
    • But if there are several terms for the first post, WPSP is going to display posts having the last term of the first post: https://hautlescours.fr/racinetest10/lieu/paris-06/. For example here, the post « L’improvisation, c’est du théâtre ! » has ‘paris-06’ as a term and ‘paris-13’ as a last one so WPSP displays ‘paris-13’ posts, and not ‘paris-06’ as expected.
    in reply to: Use WP Show Posts to Replace Blog Archive Page #32451
    Nicolas
    Participant

    Thank you Elvin,

    Your code doesn’t seem to work as is but it produces something if I replace 'tax_term' => $term, with 'tax_term' => array( $term->slug )

    The result is a bit better (now on my staging site): https://hautlescours.fr/racinetest10/lieu/__normandie/

    It displays two WPSP lists (and the regular archive list at the bottom). The first one (a small thumbnail due to CSS settings) works well, this is the only post with “__normandie” term which is what I want.

    The second WPSP list is the faulty one displaying posts with “Paris lieu variable” term.

    And the third list is the regular archives results produced by the theme (one post as expected).

    So this is getting closer, except for the fact that the code generates two wpsp lists.

    Best.

    in reply to: Use WP Show Posts to Replace Blog Archive Page #32434
    Nicolas
    Participant

    Sorry Elvin, I get back to you as my code does not work:

    add_action( 'generate_before_main_content', function(){
    if( is_tax('lieu') ){    
        $terms = get_the_terms( get_the_ID(), 'lieu' );
        foreach( $terms as $term ){
        $settings = array(
            'taxonomy' => 'lieu',
            'tax_term' => array( $term->slug ),
        );
    	}
        if ( function_exists( 'wpsp_display' ) ) {
            wpsp_display( 78685, $settings );
        }	   
    }
    }
    );

    I think adding foreach( $terms as $term ) as I tried it was not a good idea.

    Here is what happens, let’s say I go to the archive page for the term “__Normandie” of the taxonomy “Lieu”: https://hautlescours.fr/lieu/__normandie/. There is only one post with the term “__Normandie” on this page (the last one in the list). This post also has the term “Paris lieu variable” from the taxonomy “Lieu”. What seems to happen is that this archive page will give me the list of all the posts with “Paris lieu variable” posts and not those with “__Normandie”.

    Would you have any idea on how to make this work? (my goal is to use WPSP on archive pages of custom taxonomies).

    Thanks,

    Nicolas

    in reply to: Use WP Show Posts to Replace Blog Archive Page #32269
    Nicolas
    Participant

    Thank you very much Elvin,

    I could make the code work changing ‘category’ to ‘pratiques’ and adding foreach( $terms as $term ){ before $settings:

    add_action( 'generate_before_main_content', function(){
    if( is_tax('pratiques') ){    
        $terms = get_the_terms( get_the_ID(), 'pratiques' );
        foreach( $terms as $term ){
        $settings = array(
            'taxonomy' => 'pratiques',
            'tax_term' => array( $term->slug ),
        );
    	}
        if ( function_exists( 'wpsp_display' ) ) {
            wpsp_display( 77992, $settings );
        }	   
    }
    }
    );
    in reply to: Use WP Show Posts to Replace Blog Archive Page #32203
    Nicolas
    Participant

    Sorry it doesn’t work.

    But ‘pratiques’ is not a custom post type, it is a custom taxonomy.

    I registered it this way:

    add_action( 'init', 'create_pratiques_taxonomy' );
    function create_pratiques_taxonomy() {
    	register_taxonomy(
    		'pratiques', 'post',
    		array(
    			'label' => 'Activités',
    			'hierarchical' => true,
    			'public' => true,
    			'show_in_nav_menus' => true,
    			'show_tagcloud' => true,
    			'show_admin_column' => true,
    			'show_in_rest' => true,
    		)
    	);
    }
    in reply to: Use WP Show Posts to Replace Blog Archive Page #32191
    Nicolas
    Participant

    Thank you Elvin,

    I am not sure I understand. I use the following code:

    add_action( 'generate_before_main_content', function(){
    	if( is_archive() ){
    		$cat = get_category( get_query_var( 'cat' ) );
    		$cat_slug = $cat->slug;
    		if ( function_exists( 'wpsp_display' ) ) 
    		   wpsp_display( 77992, 'tax_term="' . $cat_slug . '"' 
    		);
    	}
    });

    It correctly uses the 77992 WPSP list on the archive page of categories as seen here: https://hautlescours.fr/racinetest10/category/cours-danse/classique-contemporaine-modern/

    But if I go to a custom taxonomy archive page (for example the taxonomy ‘pratiques’) I get the message “Sorry, no posts were found.”: http://hautlescours.fr/racinetest10/pratiques/barre-au-sol/ (but under this message I still see the regular archive posts list as generated by the theme).

    I was under the impression that $cat = get_category( get_query_var( 'cat' ) ); refers only to categories and would necessarily have to be changed for it to work with custom taxonomies.

    Best.

    in reply to: Use WP Show Posts to Replace Blog Archive Page #32122
    Nicolas
    Participant

    Hello,

    I found the snippet provided hereabove by Elvin works well to show posts on a category archive page using WPSP: https://gist.github.com/ejcabquina/60f052a3667da05d479749cb3be3daad

    How would I have to change this snippet for it to work with a custom taxonomy?

    Another point: add_filter( 'generate_has_default_loop', '__return_false' ); works well on my GPP theme to remove the default post loop query, but it is not the case if I add conditionals, for example if(is_archive()){ add_filter( 'generate_has_default_loop', '__return_false' );} so I am confused.

    Thanks for your help

    in reply to: Can I create this layout using WPSP Pro? #32033
    Nicolas
    Participant

    Thank you I get it, no problem it is still perfectly usable.

    in reply to: Can I create this layout using WPSP Pro? #31966
    Nicolas
    Participant

    Thank you Elvin,

    I add success reproducing my The Grid display with WPSP. I shaves off quite a few percentage points in GTMetrix scores! Here is the page I have recreated: https://hautlescours.fr/theatre/scene-theatre/

    I have a few questions:

    • I tried to adapt the code you provided hereabove for categories to a custom taxonomy (‘pratiques’). It displays the taxonomy inside the image container but it doesn’t create the class associated to the term slug. Can you correct my code please (I kept most of your variable names in the code)?
    • add_action( 'wpsp_inside_image_container', function( $settings ) {
          if ( 77954 === $settings['list_id'] || 78041 === $settings['list_id'] ) {
      		$taxonomy = 'pratiques';
              $wpsp_cat_list = get_the_term_list($post->ID, $taxonomy); 
      		$wpsp_category = get_term_link($taxonomy);
      		if ($wpsp_category) {
      			foreach($wpsp_category as $wpsp_cat) {
      			$wpsp_cat_slug = $wpsp_cat->slug; 
      			}		
      		}
      		if($wpsp_cat_list){echo '<span class="pratiques_links"><span class="'.$wpsp_cat_slug.'">'.$wpsp_cat_list.'</span></span>';} 
      	}
      });
    • To keep the same image ratio I guess it is better to define the width and height of the image in the WPSP list settings rather than trying to manage it with CSS? That’s what I have done (actually my grids with the Grid worked with generated 450*300px thumbnails, so I just reuse them with WPSP I guess if I select 450*300 in WPSP settings). I didn’t have much luck using CSS snippets found on the forum to achieve this result.

    Thanks,

    Nicolas

Viewing 14 posts - 1 through 14 (of 14 total)