Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

How do I make this PHP snippet appear in the front end?

  • Hi, I am trying to manually at Jetpack’s “share” buttons to a specific area on my website. I am following their tutorial here: https://jetpack.com/support/sharing/

    They said to add this to the area I want to display it:

    if ( function_exists( ‘sharing_display’ ) ) {
    sharing_display( ”, true );
    }

    if ( class_exists( ‘Jetpack_Likes’ ) ) {
    $custom_likes = new Jetpack_Likes;
    echo $custom_likes->post_likes( ” );
    }
    add_action( ‘loop_start’, ‘jptweak_remove_share’ );

    Right now, I want it displayed below my H1 title – however, I would like to create an element so I can have flexibility in where to display it. Do you know how I can show this PHP code on the front-end, in the place I want it? Adding it as a “Code” block just shows the text on the front end. Would converting this block of code into a shortcode work, or does generatepress include a good way to display PHP?

    Thanks so much!

  • Hi there,

    You can add it through a Hook Element.

    Just place it inside <?php and ?> and enable “Execute PHP”.

    You can create a Portable Hook so you can define a specific hook location. Creating a Portable Hook: https://generate.support/topic/create-a-shortcode-for-an-element/#post-38707

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