• I want to allow my users to embed text snippets into their own sites (most of which are blogs). For example, suppose I have 10 standard definitions for words. I want my users to be able to embed the standard definition from my site into their own. This is similar to how people embed slides from Slideshare or tweets from Twitter. How can I do this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • I believe you would need to provide them with the embed code that you have programatically generated based on what the object/item is.

    Thread Starter TomJohnson

    (@tomjohnson)

    Right, it’s that second part that I have the challenge with. Do you know of any services that would allow this sort of thing?

    You can achieve this with vary degrees of complexity, but a simple function to get you started:

    function embed_post_snippet($word, $partSpeech, $definition){
    	$output = '<code>';
    	$output .= sprintf('<h3>%1$s</h3><p><em>%2$s</em><br>%3$s</p>', $word, $partSpeech, $definition);
    	$output .= '</code>';
    	return $output;
    }

    and then in your html:

    <blockquote>
    	<?php echo embed_post_snippet('Edentulous', 'adj.', 'lacking teeth.'); ?>
    </blockquote>

    you have to replace the < and > with their respective character entities on the line that begins output .= sprintf(...

    http://codex.wordpress.org/Writing_Code_in_Your_Posts

    Thread Starter TomJohnson

    (@tomjohnson)

    Thanks. I appreciate the detail you included. I guess the challenge is still allowing php in posts. It’s possible to enable php or js via plugins that allow it in the post editor, or via shortcodes, but the idea was to allow embedding like twitter such that no restricted codes would be filtered out.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Embed text snippets into external sites’ is closed to new replies.