I am using this tooltip.
In this tooptip, I want to call image and content.
image
is showing up correctly but text is not showing up in tooptip. When I use the_content
and $content
to call text its showing error.
I have used $thumbnail[0]
to call image.
Here is code, i have call image and content:
add_shortcode('personnel', 'gdl_personnal_shortcode');
function gdl_personnal_shortcode( $atts ) {
extract( shortcode_atts(array("size"=>'1/4', 'num_fetch'=>4, "category"=>''), $atts) );
global $personnal_div_size_num_class, $sidebar_type;
$personnal = '';
$personnal_row_size = 0;
$item_size = $personnal_div_size_num_class[$size][$sidebar_type];
$post_temp = query_posts(array('post_type'=>'personnal',
'personnal-category' => $category, 'posts_per_page'=>$num_fetch)
);
$personnal = $personnal . '<div class="personnal-item-holder">';
while( have_posts() ){ the_post();
$ret_size = return_item_size($size, $personnal_row_size, 'personnal-item-wrapper');
$personnal_row_size = $ret_size['row-size'];
$personnal = $personnal . $ret_size['return'];
$personnal = $personnal . '<div class="personnal-item">';
$personnal = $personnal . '<div class="personnal-title">';
$personnal = $personnal . get_the_title();
$personnal = $personnal . '</div>';
$ids=get_the_ID();
$position = get_post_meta( get_the_ID(), 'personnal-option-position', true );
if( !empty($position) ){
$personnal = $personnal . '<div class="personnal-position">' . $position . "</div>";
}
$thumbnail_id = get_post_thumbnail_id();
$thumbnail = wp_get_attachment_image_src( $thumbnail_id , $item_size );
$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
if( !empty($thumbnail) ){
$personnal = $personnal . '<div class="sc-tooltip" data-image="' . $thumbnail[0] . '" data-desc="'.'"><div class="personnal-thumbnail"><a href="#" onclick="abctext('.$ids.')" ><img src="' . $thumbnail[0] . '" alt="' . $alt_text . '"></a></div></div>';
}
the Tooltip loos like this:
But its has a text in the right side of the image which is not showing right now.
You need to use
get_the_content()
to return the post content as a variable rather than echoing it – you can assign this to$content
. You can then append this to the$personal
string.I have made change in
$pearsonnal
string:-