%s', 'appointment'),
array(
'span' => array(
'class' => array(),
),
)
),
get_the_title()
),
'',
''
);
}
endif;
/* Related Post section */
function appointment_related_post() {
if( get_post_type() != 'post' ) return;
$related_post_enable = get_theme_mod('related_post_enable',true);
if( !$related_post_enable ) return;
$related_posts_title = get_theme_mod('single_post_related_posts_title','Related News');
// Get the current post's ID
$current_post_id = get_the_ID();
// Get the categories of the current post
$categories = get_the_category($current_post_id);
if ($categories!=null) {
$category_ids = array();
foreach ($categories as $category) {
$category_ids[] = $category->term_id;
}
// Query related posts based on the category IDs
$args = array(
'post__not_in' => array($current_post_id), // Exclude the current post
'category__in' => $category_ids, // Include posts from the same categories
'posts_per_page' => 3, // Adjust the number of related posts to display
);
$related_posts_query = new WP_Query($args);
// Display related posts
if (!$related_posts_query->have_posts()) return; ?>
' .esc_html( $related_posts_title ). '
';
while ($related_posts_query->have_posts()) {
$related_posts_query->the_post();
// Display related post content, title, etc. ?>