Support » Plugins » Hacks » Shortcode for the_meta()

  • rrddzzz


    I have shortcode to display individual keys but need one to display all keys.
    Has anyone crated a shortcode to display all meta keys like the function the_meta() does?

    function the_meta() {
            if ( $keys = get_post_custom_keys() ) {
                    echo "<ul class='post-meta'>\n";
    	                foreach ( (array) $keys as $key ) {
    	                        $keyt = trim($key);
    	                        if ( is_protected_meta( $keyt, 'post' ) )
    	                        $values = array_map('trim', get_post_custom_values($key));
    	                        $value = implode($values,', ');
    	                        echo apply_filters('the_meta_key', "
    <li><span class='post-meta-key'>$key:</span> $value</li>
    \n", $key, $value);
    	                echo "\n";

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum’s parser.]

Viewing 1 replies (of 1 total)
  • Moderator bcworkz


    Wouldn’t be hard to create. Use the same function definition for the shortcode handler function definition, except instead of echo outs, concatenate the same into a string, and then finally, return the string.

Viewing 1 replies (of 1 total)
  • The topic ‘Shortcode for the_meta()’ is closed to new replies.