Support Forum

Please login to receive premium support.

Support for the free plugin can be found here.

Samuel

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 56 total)
  • Author
    Posts
  • in reply to: Related Post #22527
    Samuel
    Participant

    Ok, I understand 🙂 Thanks a lot Tom !

    in reply to: Related Post #22497
    Samuel
    Participant

    Ok, so there is a misunderstanding.

    I’m showing 4 related posts and I was asking if it’s possible to show posts from another category or from a parent category in the case there is less then 4 posts in a child category.

    Don’t know if this make sense…

    in reply to: Related Post #22451
    Samuel
    Participant

    Hi Tom,

    Here was the first code that was resolving the issue of “Display Child Category, and if there is not then display Parent Category” :

    // Remove first category, assuming it's a parent.
    if ( count( $cat_values ) > 1 ) {
        unset( $cat_values[0] );
    }

    If as you suggest I replace it with :

    // Remove first category as long as there's more than 4 categories.
    if ( count( $cat_values ) > 4 ) {
        unset( $cat_values[0] );
    }

    It’s displaying parent category everywhere, so first issue is coming back and it’s not displaying Child category when there is one.

    What would be awesome is :

    1 / Priority is “Get Child Category”
    2 / Then “If there is no Child Category then Get Category”
    3 / And “If there is less then 4 items in a Child Category then get Category”

    Would that be possible ?

    in reply to: Related Post #22293
    Samuel
    Participant

    Sorry about that, it shows “no posts were found” because there is only one post inside this category… so it’s normal !

    To go further, I’m showing 4 related posts : Would it possible to tell WPSP to show other posts from parent category or from other category if there is less than 4 posts in the current category ?

    in reply to: Related Post #22225
    Samuel
    Participant

    It seems to work ! 🙂 WPSP is displaying child category on post with child category and when post has no child category it’s displaying the category.

    The only thing really weird is i got just one category and its child category that is displaying a “Sorry, no posts were found.”

    in reply to: Related Post #22221
    Samuel
    Participant

    Hi Tom,

    Yes, “santander” a child category within the “andes” category

    in reply to: Related Post #22175
    Samuel
    Participant

    Hi Tom,

    Here you go :

    array(7) { ["order"]=> string(3) "ASC" ["orderby"]=> string(6) "parent" ["post_type"]=> string(4) "post" ["posts_per_page"]=> int(4) ["post_status"]=> array(1) { [0]=> string(7) "publish" } ["tax_query"]=> array(1) { [0]=> array(4) { ["taxonomy"]=> string(8) "category" ["field"]=> string(4) "slug" ["terms"]=> array(2) { [0]=> string(6) ""andes" [1]=> string(10) "santander"" } ["operator"]=> string(2) "IN" } } ["post__not_in"]=> array(1) { [0]=> int(22765) } }

    in reply to: Related Post #22131
    Samuel
    Participant

    Hi Tom,

    Unfortunately this snipet is displaying posts from category but not from sub-category.

    in reply to: Related Post #22008
    Samuel
    Participant

    Here it is with Wp-debug=True

    Fatal error: Uncaught Error: Cannot use object of type WP_Term as array in /home/movoco/public_html/wp-content/plugins/gp-premium/elements/class-hooks.php(196) : eval()'d code:10 Stack trace: #0 /home/movoco/public_html/wp-content/plugins/gp-premium/elements/class-hooks.php(196): eval() #1 /home/movoco/public_html/wp-includes/class-wp-hook.php(287): GeneratePress_Hook->execute_hook('') #2 /home/movoco/public_html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters('', Array) #3 /home/movoco/public_html/wp-includes/plugin.php(478): WP_Hook->do_action(Array) #4 /home/movoco/public_html/wp-content/themes/generatepress/content-single.php(99): do_action('generate_after_...') #5 /home/movoco/public_html/wp-includes/template.php(732): require('/home/movoco/pu...') #6 /home/movoco/public_html/wp-includes/template.php(676): load_template('/home/movoco/pu...', false, Array) #7 /home/movoco/public_html/wp-includes/general-template.php(204): locate_template(Array, true, false, Array) #8 /home/movoco/public_html/wp-content/them in /home/movoco/public_html/wp-content/plugins/gp-premium/elements/class-hooks.php(196) : eval()'d code on line 10

    in reply to: Related Post #21954
    Samuel
    Participant

    Hi Tom,

    It’s not working, it’s breaking my layout and displaying a “critical error” message where WPSP is supposed to display.

    in reply to: WPML and "Read more…" translation problems #21950
    Samuel
    Participant

    Oh sorry, my bad, with the confusion of the our 2 different issues (redirection and translation) there was 2 functions conflicting, now it’s working, and here is the final word :

    <?php
    
    add_filter( 'wpsp_title_href', function( $href ) {
        $custom_url = get_post_meta( get_the_ID(), 'url-booking', true );
    
        if ( $custom_url ) {
            return $custom_url;
        }
    
        return $href;
    } );
    
    add_filter( 'wpsp_image_href', function( $href ) {
        $custom_url = get_post_meta( get_the_ID(), 'url-booking', true );
    
        if ( $custom_url ) {
            return $custom_url;
        }
    
        return $href;
    } );
    
    add_filter( 'wpsp_read_more_output', function( $output, $settings ) {
        $custom_url = get_post_meta( get_the_ID(), 'url-booking', true );
    
        if ( $custom_url ) {
            return sprintf(
                '<div class="wpsp-read-more"><a title="%1$s" class="%4$s" href="%2$s">%3$s</a></div>',
                the_title_attribute( 'echo=0' ),
                esc_url( $custom_url ),
                __( 'Voir les tarifs', 'wp-show-posts' ),
                esc_attr( $settings['read_more_class'] )
            );
        }
    
        return $output;
    }, 10, 2 );
    
    add_filter( 'wpsp_terms_output', function( $output ) {
        return strip_tags( $output );
    } );

    ?>`

    in reply to: WPML and "Read more…" translation problems #21946
    Samuel
    Participant

    Hi Tom,

    Thanks again for your time, your support is amazing, but it’s not working. Here is the entire hook we are using combining custom redirection + read more translation :

    <?php
    
    add_filter( 'wpsp_title_href', function( $href ) {
        $custom_url = get_post_meta( get_the_ID(), 'url-booking', true );
    
        if ( $custom_url ) {
            return $custom_url;
        }
    
        return $href;
    } );
    
    add_filter( 'wpsp_image_href', function( $href ) {
        $custom_url = get_post_meta( get_the_ID(), 'url-booking', true );
    
        if ( $custom_url ) {
            return $custom_url;
        }
    
        return $href;
    } );
    
    add_filter( 'wpsp_read_more_output', function( $output, $settings ) {
        $custom_url = get_post_meta( get_the_ID(), 'url-booking', true );
    
        if ( $custom_url ) {
            return sprintf(
                '<div class="wpsp-read-more"><a title="%1$s" class="%4$s" href="%2$s">%3$s</a></div>',
                the_title_attribute( 'echo=0' ),
                esc_url( $custom_url ),
                __( 'Read more', 'wp-show-posts' ),
                esc_attr( $settings['read_more_class'] )
            );
        }
    
        return $output;
    }, 10, 2 );
    
    add_filter( 'wpsp_terms_output', function( $output ) {
        return strip_tags( $output );
    } );
    
    add_filter( 'wpsp_read_more_output', function( $output, $settings ) {
        return sprintf(
            '<div class="wpsp-read-more"><a title="%1$s" class="%4$s" href="%2$s">%3$s</a></div>',
            the_title_attribute( 'echo=0' ),
            esc_url( get_permalink() ),
            __( 'Voir les tarifs', 'wp-show-posts' ),
            esc_attr( $settings['read_more_class'] )
        );
    }, 10, 2 );
    
    ?>
    in reply to: Related Post #21837
    Samuel
    Participant

    Hi,

    This is provoquing a critical error.

    We agree that the entire function would be like this ?

    <?php if ( is_single() ) {
        $cat = array();
    
        $cats =  get_the_category();
    
        foreach ( $cats as $cat ) {
            $cat[] = $cat->slug;
        }
    } else {
        $cat = get_category( get_query_var( 'cat' ) );
    }
    
    $cat_slug = $cat->slug;
    $list = get_page_by_title( 'related', 'OBJECT', 'wp_show_posts' );
    wpsp_display( $list->ID, 'tax_term="' . $cat_slug . '"' );
    ?>
    in reply to: WPML and "Read more…" translation problems #21832
    Samuel
    Participant

    Hi Tom,

    This is working for styling issue perfectly, thanks !

    But this function is still breaking the job we’ve done together regarding the “redirecting to custom url” thing (reply #20708)

    in reply to: WPML and "Read more…" translation problems #21794
    Samuel
    Participant

    Sorry Tom, about that mess in my different message, but here is what I found :

    My redirection problem was that as WPML didn’t allow me to translated url custom field (I have to see that with them) the url custom field in my spanish post translation was empty. SO, I added it manually. And now you can see what is happening : https://miviajeporcolombia.com/test-33-es/

    When specifying url in post custom field, WPSP button’s style is display well BUT in French… it’s quite crazy what’s it’s happening here.

Viewing 15 posts - 1 through 15 (of 56 total)