-
Notifications
You must be signed in to change notification settings - Fork 0
/
single.php
139 lines (131 loc) · 7.95 KB
/
single.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
/**
* The template for displaying all single posts and attachments
*/
get_header();
get_template_part('template-parts/content/breadcrumb');
?>
<!-- Blog Details Section Begin -->
<section class="blog-details spad">
<div class="container">
<div class="row">
<div class="col-lg-4 col-md-5 order-md-1 order-2">
<?php if ( is_active_sidebar( 'blog-sidebar' ) ) { ?>
<ul id="sidebar">
<?php dynamic_sidebar('blog-sidebar'); ?>
</ul>
<?php } ?>
</div>
<div class="col-lg-8 col-md-7 order-md-1 order-1">
<?php
// Get product categories
$category = get_the_category();
if ( ! empty( $category ) ) {
$category_name = esc_html( $category[0]->name );
} else {
$category_name = esc_html__( 'Uncategorized', 'text-domain' );
}
// Get product tags
$product_tags = get_the_terms( get_the_ID(), 'product_tag' );
if ( ! empty( $product_tags ) && ! is_wp_error( $product_tags ) ) {
$tag_names = array();
foreach ( $product_tags as $tag ) {
$tag_names[] = esc_html( $tag->name );
}
$tags_list = implode( ', ', $tag_names );
} else {
$tags_list = esc_html__( 'No tags', 'text-domain' );
}
if( have_posts() ) {
while( have_posts() ) : the_post();
?>
<div class="blog__details__text">
<?php the_content(); ?>
</div>
<div class="blog__details__content">
<div class="row">
<div class="col-lg-6">
<div class="blog__details__author">
<div class="blog__details__author__pic">
<img src="<?php echo esc_url( get_avatar_url( get_the_author_meta( 'ID' ) ) ); ?>" alt="<?php echo esc_attr( get_the_author_meta( 'display_name' ) ); ?>">
</div>
<div class="blog__details__author__text">
<h6><?php echo esc_html( get_the_author_meta( 'display_name' ) ); ?></h6>
<span>
<?php
$user_meta = get_userdata( get_the_author_meta( 'ID' ) );
if ( ! empty( $user_meta->roles ) ) {
echo esc_html( ucfirst( $user_meta->roles[0] ) );
}
?>
</span>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="blog__details__widget">
<ul>
<li><span>Categories:</span>
<?php
$categories = get_the_category();
if ($categories) {
foreach ($categories as $category) {
echo esc_html($category->name) . ', ';
}
} else {
echo 'No categories';
}
?>
</li>
<li><span>Tags:</span>
<?php
$tags = get_the_tags();
if ($tags) {
foreach ($tags as $tag) {
echo esc_html($tag->name) . ', ';
}
} else {
echo 'No tags';
}
?>
</li>
</ul>
<div class="blog__details__social">
<?php
$post_title = get_the_title();
$post_url = get_permalink();
$post_url_encoded = urlencode($post_url);
$post_title_encoded = urlencode($post_title);
?>
<a href="https://www.facebook.com/sharer/sharer.php?u=<?= get_permalink(); ?>" target="_blank" rel="noopener noreferrer">
<i class="fa-brands fa-facebook"></i>
</a>
<a href="https://twitter.com/intent/tweet?text=<?php echo $post_title_encoded; ?>&url=<?php echo $post_url_encoded; ?>" target="_blank" rel="noopener noreferrer">
<i class="fa-brands fa-twitter"></i>
</a>
<a href="https://plus.google.com/share?url=<?php echo $post_url_encoded; ?>" target="_blank" rel="noopener noreferrer">
<i class="fa-brands fa-google-plus"></i>
</a>
<a href="https://www.linkedin.com/shareArticle?mini=true&url=<?php echo $post_url_encoded; ?>&title=<?php echo $post_title_encoded; ?>" target="_blank" rel="noopener noreferrer">
<i class="fa-brands fa-linkedin"></i>
</a>
<a href="mailto:?subject=<?php echo $post_title_encoded; ?>&body=<?php echo $post_url_encoded; ?>" target="_blank" rel="noopener noreferrer">
<i class="fa-solid fa-envelope"></i>
</a>
</div>
</div>
</div>
</div>
</div>
<?php
endwhile;
} else {
__('No post found', 'ogani');
}
?>
</div>
</div>
</div>
</section>
<!-- Blog Details Section End -->
<?php get_footer() ?>