• Hi everybody
    I’m looking for help to create a shortcode which calls specific field from commentmeta – meta_value.

    Here is the sql query :

    <? $select = "SELECT meta_value FROM " . "$wpdb->commentmeta WHERE meta_key='pmg_comment_title' AND meta_value!=''";
    		$requete = $wpdb->get_results($select);
    		foreach($requete as $ligne){?>
    
    		<?php echo $ligne->meta_value; echo'<br/>';
    		}
    		?>

    The begining of the fucntion should be ?

    function MYshorcode_shortcode( $atts )
    {
    /// I don't know how to call sql
    add_shortcode('MYshortcode', 'MYshortcode_shortcode');

    I’m newbie in WP hack, so I don’t understand how to create a function then a shortcode to make the query works in a widget.

    I’ve also add to my function.php file :
    add_filter('widget_text', 'do_shortcode');

    Thank’s for your help !

    (excuse my bad english ;))

The topic ‘function shortcode to create plugin : latest comments meta_value’ is closed to new replies.