• Resolved JoeVenables

    (@joevenables)


    Hello,

    I am working on a site for an author, using GeneratePress Premium. I am intending to use WP Show Posts to display a List of all their published works. The List will show an excerpt with a Read More button.

    Alongside the Read More button I would like to display a Buy Book button, which will link to an external site.

    My idea for how to do this is to use a Custom Field, buy-book, for which the value is the external URL. I think I could display this using the method here: https://wpshowposts.com/support/topic/output-custom-field-in-div-class/

    I have three questions:

    Do you think that method would work for what I am trying to achieve?
    Do I need the Pro version of the plugin to use that method?
    How exactly do I go about hooking the code into the plugin; where do I need to paste the code?

    (Please excuse my ignorance on the last question, I am not experienced with PHP).

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tom

    (@edge22)

    Hi there,

    You should be able to use a filter for that.

    Something like this:

    add_filter( 'wpsp_read_more_output', function( $output ) {
        $buy_book = get_post_meta( get_the_ID(), '_buy_book_field', true );
        $buy_book_button = '';
    
        if ( $buy_book ) {
            $buy_book_button = '<a class="buy-book" href="' . $buy_book . '">Buy Book</a>';
        }
    
        echo $output . $buy_book_button;
    } );

    Let me know if you need more info ??

    Thread Starter JoeVenables

    (@joevenables)

    Great, thanks Tom!

    Plugin Author Tom

    (@edge22)

    You’re welcome ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Adding 2nd Button Alongside Read More’ is closed to new replies.