Last active
April 21, 2020 21:08
-
-
Save meetKowshik/b3a5f322d84ab3d1138e75db311b4618 to your computer and use it in GitHub Desktop.
Showing only the listing that are bookmarked by the user in Directories Pro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function theme_free_user_bookmarkedlisting_shortcode( $atts, $content= null ) { | |
$user = wp_get_current_user(); | |
$current_user_id = $user->ID; | |
$base_url = get_site_url(); | |
global $wpdb; | |
$listingEntityId = $wpdb->get_results("SELECT vote_entity_id FROM wp_yjigapdowy_drts_voting_vote WHERE vote_field_name = 'voting_bookmark' AND vote_bundle_name='practitioner_dir_ltg' AND vote_user_id = $current_user_id AND vote_value = '1.00' "); | |
$listingId = array(); | |
foreach ($listingEntityId as $value) { | |
$listingId[] = $value->vote_entity_id; | |
} | |
$output = ''; | |
$output .= '<div class="dashboard__box">'; | |
if(count($practitionersId) > 0) { | |
$output .= '<ul class="list__item">'; | |
foreach ($listingId as $id) { | |
$listingposts= get_post($id); | |
$post_id = $listingposts->ID; | |
$post_title = $listingposts->post_title; | |
$post_link = $listingposts->post_name; | |
$newQuery = $wpdb->get_results("SELECT guid FROM wp_yjigapdowy_posts WHERE post_parent = $id"); | |
if($post_title) { | |
$output .= '<li data-id="'.$post_id.'">'; | |
$output .= '<a href="'.$base_url.'/'.$post_link.'">'; | |
foreach($newQuery as $key => $post_image) { | |
if($key === 0) { | |
$output .= '<img src="'.$post_image->guid.'" alt="'.$post_title.'">'; | |
} | |
} | |
$output .= '<h3>'.$post_title.'</h3>'; | |
$output .= '</a>'; | |
$output .= '</li>'; | |
} | |
} | |
$output .= '</ul>'; | |
} else { | |
$output .= "<p>There's no Practitioners to show</p>"; | |
} | |
$output .= '</div>'; | |
return $output; | |
} | |
add_shortcode('showonlybookmarkedlisting', 'theme_free_user_bookmarkedlisting_shortcode'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment