• Resolved bunnylumpkins

    (@bunnylumpkins)


    Hello,

    I’ve created my template and it’s working great, save for the fact I can’t get the purchase or good reads buttons to work. I’m admittedly not super great with php, but can usually edit. I’m sure I’ve made an obvious mistake, but was wondering if you could tell me where I went wrong?

    $book = new Novelist_Book( get_the_ID() );
    
    if ( $book->title ) {
        echo '<h2>' . esc_html( $book->title ) . '</h2>';
    }
    if ( $book->series_name ) {
        echo '<h3>' . ( $book->series_name ) . '</h3>';
    }
    
        echo '<blockquote class="novelist-synopsis">' . wpautop( $book->synopsis ) . '</blockquote>';
    
    ?>
    
    <div id=“amazon”><?php echo $book->purchase_links; ?></div>
    <div id=“goodreads”><?php echo $book->goodreads_link; ?></div>

    This returns the text “Array” followed by the URL for Goodreads, not the button I uploaded per the instructions that works splendidly if I use the regular template.

    • This topic was modified 7 years, 7 months ago by bunnylumpkins.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Ashley

    (@nosegraze)

    Hi!

    $book->purchase_links returns an array – not a string. That’s why you’re not seeing the expected results. For what you’re doing, you might want to do echo $book->get_formatted_purchase_links() instead.

    Thread Starter bunnylumpkins

    (@bunnylumpkins)

    Thank you! And I’m assuming that should work for the GoodReads link as well?

    Plugin Author Ashley

    (@nosegraze)

    $book->goodreads_link just prints the URL to Goodreads. If you want to print the text in the book info settings too, you’d want to use $book->render( 'goodreads_link' );

    Thread Starter bunnylumpkins

    (@bunnylumpkins)

    Thank you so much!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can’t get buttons to populate’ is closed to new replies.