• Resolved Richard-B

    (@richard-b)


    Hi, great plugin, nice and fast too ??
    Is there a shortcode or function that can be used in theme files where we can use the URL of a page?

    Like [visual-link-preview url="https://google.com"]

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Brecht

    (@brechtvds)

    Happy to hear you’re enjoying the plugin!

    There is a shortcode, but it only takes an encoded parameter at the moment. The easiest way would be to create a VLP in the regular editor and then switch to code view to copy and paste the shortcode to use in your theme files.

    Thread Starter Richard-B

    (@richard-b)

    Hi, thanks so much for getting back to me so quickly. Thats a good solution, however we wanted to use a variable where the URL would be so it pulls in the embeds dynamically like this:

    $url = (something from a custom field);
    do_shortcode('[visual-link-preview url="'.$url.'"]);

    Thanks again

    Plugin Author Brecht

    (@brechtvds)

    I’m afraid that’s not possible right now.
    What are you trying to achieve specifically?

    Thread Starter Richard-B

    (@richard-b)

    We have a section of our site which has user submitted links, we very much wanted to emulate the Facebook style link previews which your plugin produces for this area.
    Links are submitted through the front-end of the site so we cannot use the VLP in the regular editor.

    Plugin Author Brecht

    (@brechtvds)

    Well technically that encoded attribute is just a base64 and JSON encoded array, so you could construct it yourself like this:

    $encoded = base64_encode(
    	json_encode(
    		array(
    			'type' => 'external',
    			'url' => '',
    			'image_id' => '',
    			'image_url' => '',
    			'title' => '',
    			'summary' => '',
    			'template' => '',
    		)
    	)
    );
    Thread Starter Richard-B

    (@richard-b)

    Amazing, that will work, thank you so much for your help and support

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Shortcode’ is closed to new replies.