-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle.php
159 lines (126 loc) · 5.38 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
/**
* Genesis Framework.
*
* WARNING: This file is part of the core Genesis Framework. DO NOT edit this file under any circumstances.
* Please do all modifications in the form of a child theme.
*
* @package Genesis\Templates
* @author StudioPress
* @license GPL-2.0-or-later
* @link https://my.studiopress.com/themes/genesis/
*/
// This file handles single entries, but only exists for the sake of child theme forward compatibility.
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
add_action('genesis_before_content', function(){
$categories = get_the_category();
$separator = ' | ';
$output = '';
?>
<div class="wp-block-group custom-blog-entry-heading blue-pattern">
<div class="wp-block-group__inner-container">
<div class="wp-block-group fixed-1180 entry-header-wrap">
<div class="wp-block-group__inner-container">
<span class="post-category">
<?php
if ( ! empty( $categories ) ) {
foreach( $categories as $category ) {
$output .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" alt="' . esc_attr( sprintf( __( 'View all posts in %s', 'textdomain' ), $category->name ) ) . '">' . esc_html( $category->name ) . '</a>' . $separator;
}
echo trim( $output, $separator );
}
?>
</span>
<h1><?php the_title() ?></h1>
<p class="post-meta"><span class="date"><?php echo get_the_date(); ?></span>
<span class="author-span">by <?php echo get_the_author(); ?></span></p>
</div>
</div>
</div>
</div>
<?php });
function art_cats_related_post() {
$post_id = get_the_ID();
$cat_ids = array();
$categories = get_the_category( $post_id );
if(!empty($categories) && is_wp_error($categories)):
foreach ($categories as $category):
array_push($cat_ids, $category->term_id);
endforeach;
endif;
$current_post_type = get_post_type($post_id);
$query_args = array(
'category__in' => $cat_ids,
'post_type' => $current_post_type,
'post__not_in' => array($post_id),
'posts_per_page' => '4'
);
$related_cats_post = new WP_Query( $query_args );
?>
<div class="recent-wrap recent-entries"><div class="recent-wrap-in">
<?php
if($related_cats_post->have_posts()):
while($related_cats_post->have_posts()): $related_cats_post->the_post(); ?>
<div class="cat-post">
<div class="cat-post-in">
<p class="date"><time datetime="<?php echo get_the_date(); ?>" itemprop="datePublished"><?php echo get_the_date(); ?></time></p>
<h3 class="blog-post-title"><a href="<?php the_permalink(); ?>"><?php the_title() ?></a></h3>
<?php
// the_excerpt();
?>
</div>
</div>
<?php endwhile;
// Restore original Post Data
wp_reset_postdata();
endif;
?>
</div></div>
<?php
}
add_action('genesis_after_content', function(){ ?>
<div class="wp-block-columns is-layout-flex wp-container-7 wp-block-columns-is-layout-flex author-bio">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow thumbnail-auth">
<?php
$theme_directory_uri = get_stylesheet_directory_uri();
$default_image_url = $theme_directory_uri . '/images/avatar.jpg'; // Replace with the correct path to your fallback image
$author_email = get_the_author_meta('user_email');
$gravatar_url = get_avatar_url($author_email, array('size' => 100, 'default' => $default_image_url));
?>
<img src="<?php echo esc_url($gravatar_url); ?>" alt="<?php echo get_the_author(); ?>" width="100" height="100" onerror="this.src='<?php echo esc_url($default_image_url); ?>';">
</div>
<div class="wp-block-column is-vertically-aligned-top is-layout-flow wp-block-column-is-layout-flow author-bio-in">
<h3> <?php echo get_the_author(); ?></h3>
<p><?php echo get_the_author_meta('description'); ?></p>
</div>
</div>
<div class="rel-posts gray-bg">
<div class="rel-posts-box">
<?php
// Check if on single 'announcement' CPT page.
if ( is_singular('announcement') ) :
if ( is_active_sidebar( 'related-announcement-title' ) ) : ?>
<div class="rel-posts-title">
<?php dynamic_sidebar( 'related-announcement-title' ); ?>
</div>
<?php endif;
endif;
// Check if on a standard single post.
if ( is_singular('post') ) :
if ( is_active_sidebar( 'related-post-title' ) ) : ?>
<div class="rel-posts-title">
<?php dynamic_sidebar( 'related-post-title' ); ?>
</div>
<?php endif;
endif;
?>
<div class="rel-posts-in">
<?php art_cats_related_post() ?>
</div>
</div>
</div>
<?php }); ?>
<?php
genesis();