We're merging with GenerateBlocks! Learn more here.

[Resolved] Custom URL

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Custom URL

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • #18361
    Samuel
    Participant

    Hi,

    I already post my question on the Generate Press forum but maybe better if I’m asking here :

    Basically I want to redirect to a custom URL. Custom URL that would be calling from a custom field present in each post.

    In each post I have a custom field, name is “url-booking” and value is the custom URL. I think the call would be something like get_field($url-booking); but I really don’t know how to configure it with WPSP.

    Hope this is clear enough,
    Thanks a lot,
    Samuel

    #18363
    Samuel
    Participant

    Hi again,

    I just wanted to add that I would need this only for custom post types called “hotel”.

    I really don’t speak the php and it’s frustrating because I know it would something like “if post is hotel then link to custom url”

    I saw a reply you made regarding a similar request for gallery

    So would it be something like this possible ?

    add_filter( 'wpsp_post_href', function( $href ) {
        if ( 'hotel' == get_post_type() ) {
            return get_field($url-booking);
        }
    
        return $href;
    } );
    #18374
    Tom
    Keymaster

    Hi there,

    As of right now, no filter exists there.

    I agree that it would be a good filter to have – I’ve made a note of this for the next version.

    #18378
    Samuel
    Participant

    Thanks for your reply Tom,

    Just to know what’s the next step for me, do you have any idea about when a new version would be released ?

    #18391
    Tom
    Keymaster

    We had a meeting about this yesterday. We’ll be trying to get an update out for free and pro within a month.

    #18432
    Samuel
    Participant

    Thanks a lot

    #18439
    Tom
    Keymaster

    No problem 🙂

    #19164
    Samuel
    Participant

    Hi Tom,

    Can you confirm me you’re adding this filter we were talking about in the next update coming ?

    Thanks a lot

    #19185
    Tom
    Keymaster

    Hi there,

    Yes, you can see it here in 1.2: https://github.com/tomusborne/wp-show-posts/blob/release/1.2/wp-show-posts.php#L460

    We’ll be entering alpha testing soon 🙂

    #19241
    Samuel
    Participant

    Great news ! Thanks Tom

    #19247
    Tom
    Keymaster

    No problem! 🙂

    #20603
    Samuel
    Participant

    Hi Tom,

    Coming back to do some tests with your Alpha 1.2 version.

    Could you help me understand how to implement the “get custom url” function we were talking about ?

    To remind you what I’m trying to do is :

    I have hotel pages where I use a custom field I called “url-booking” and where I put an URL.
    I need WP Show Post to link to this “url-booking” custom URL

    Here is a example of what I’m doing right now using another (but heavy) plugin : https://monvoyageencolombie.com/ou-loger-region-caraibe/

    Thanks for your help,
    Samuel

    #20615
    Tom
    Keymaster

    Hi there,

    You can do this:

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

    Hope this helps!

    #20651
    Samuel
    Participant

    Hi Tom,

    The function is working well but partially, Title’s link is redirecting to the custom URL fine, but Image and Button’s link are redirecting to the original page…

    Is this possible to make all links to redirect to custom URL ?

    Thanks for your help,
    Sam

    #20708
    Tom
    Keymaster

    For the image, you can duplicate the function but use wpsp_image_href as the filter name.

    For the button, try this:

    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 ),
                $settings['read_more_text'],
                esc_attr( $settings['read_more_class'] )
            );
        }
    
        return $output;
    }, 10, 2 );
Viewing 15 posts - 1 through 15 (of 25 total)
  • You must be logged in to reply to this topic.