We're merging with GenerateBlocks! Learn more here.

[Resolved] Meta fields as buttons in hook

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Meta fields as buttons in hook

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1392
    Jamal
    Participant

    Hi

    As an alternative to my other buttons question,i would like to put two buttons like this in one of the hooks. The buttons will be a “Read More” and “Visit Site” with both preferably fetching their url from custom post metafields. How would i go about it? Thanks

    #1393
    Jamal
    Participant

    Ok i realized i asked you a similar question before and this is how far i have come now

    //Kundcase show links instead of content
    add_action( 'wpsp_before_content','wpsp_add_custom_meta' );
    function wpsp_add_custom_meta()
    {
        $meta = get_post_meta( get_the_ID(), 'kundcase_site_url', true );
    
        if ( isset( $meta ) && '' !== $meta )
            echo '<a class="button" href="'.$meta.'">Besök sidan</a>';
    }

    How can i fetch and show post permalink beside this link?

    #1395
    Jamal
    Participant

    Well i think this one is solved, please take a look if you can and let me know if there is a simpler or better way to do it

    //Wpsp show meta instead of content
    add_action( 'wpsp_before_content','wpsp_add_custom_meta' );
    function wpsp_add_custom_meta()
    {
        $meta = get_post_meta( get_the_ID(), 'kundcase_site_url', true );
    
        if ( isset( $meta ) && '' !== $meta )
            echo '<a class="button" href="'.$meta.'">Besök sidan</a>';
    
        echo '<a class="button alignright" href="'.get_permalink( $id ).'">Läs Mer</a>';
    }
    #1396
    Tom
    Keymaster

    That’s perfect – exactly how I would do it.

    The other question will require me to make some changes to the core plugin I think. Battling a cold right now, but will get to it ASAP 🙂

    #1397
    Jamal
    Participant

    Thanks for your awesome products and even better support. I’m in no hurry regarding the other question, get well soon.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.