add canonical authors

This commit is contained in:
argoexpert press
2025-04-22 22:54:20 +03:00
parent 3d8a4a5054
commit 1c4b27d358
6 changed files with 26 additions and 7 deletions

View File

@@ -17,7 +17,7 @@
$query = new WP_Query($args); $query = new WP_Query($args);
?> ?>
<?php get_template_part('partials/post-list', null, ['large_first_image' => false, 'query' => $query]); ?> <?php get_template_part('partials/post-list', null, ['large_first_image' => false, 'query' => $query]); ?>
<div class="frontpage-next"><a href="https://agroexpert.press/category/all-events/page/2/">Еще новости</a></div> <div class="frontpage-next"><a href="https://agroexpert.press/all-events/page/2/">Еще новости</a></div>
</div> </div>
</div> </div>
<?php get_footer(); ?> <?php get_footer(); ?>

View File

@@ -639,9 +639,9 @@ function custom_meta_tags() {
$term = get_queried_object(); $term = get_queried_object();
$canonical_url = get_term_link($term); $canonical_url = get_term_link($term);
if ($paged > 1) { //if ($paged > 1) {
$meta_tags .= '<link rel="canonical" href="' . esc_url($canonical_url) . '" />' . PHP_EOL; $meta_tags .= '<link rel="canonical" href="' . esc_url($canonical_url) . '" />' . PHP_EOL;
} // }
$title = $term->name . ' - ' . $sitename; $title = $term->name . ' - ' . $sitename;
$description = !empty(trim($term->description)) ? $term->description : $term->name; $description = !empty(trim($term->description)) ? $term->description : $term->name;
@@ -657,6 +657,25 @@ function custom_meta_tags() {
$og_tags .= '<meta property="og:title" content="' . esc_html($title) . '" />' . PHP_EOL; $og_tags .= '<meta property="og:title" content="' . esc_html($title) . '" />' . PHP_EOL;
$og_tags .= '<meta property="og:description" content="' . esc_attr($description) . '" />' . PHP_EOL; $og_tags .= '<meta property="og:description" content="' . esc_attr($description) . '" />' . PHP_EOL;
} elseif (is_author()) {
$author = get_queried_object();
$author_name = $author->display_name;
$author_description = get_the_author_meta('description', $author->ID);
$canonical_url = get_author_posts_url($author->ID);
$title = 'Материалы автора ' . $author_name . ' - ' . $sitename;
$description = !empty($author_description) ? $author_description : 'Материалы, опубликованные автором ' . $author_name;
$meta_tags .= '<title>' . esc_html($title) . '</title>' . PHP_EOL;
$meta_tags .= '<meta name="description" content="' . esc_attr($description) . '">' . PHP_EOL;
$meta_tags .= '<meta name="author" content="' . esc_attr($author_name) . '">' . PHP_EOL;
$meta_tags .= '<link rel="canonical" href="' . esc_url($canonical_url) . '" />' . PHP_EOL;
$og_tags .= '<meta property="og:url" content="' . esc_url($canonical_url) . '" />' . PHP_EOL;
$og_tags .= '<meta property="og:title" content="' . esc_html($title) . '" />' . PHP_EOL;
$og_tags .= '<meta property="og:description" content="' . esc_attr($description) . '" />' . PHP_EOL;
} elseif (is_single() || is_page()) { } elseif (is_single() || is_page()) {
$post = get_queried_object(); $post = get_queried_object();

View File

@@ -135,7 +135,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<?php get_template_part('partials/pinned-post'); ?> <?php get_template_part('partials/pinned-post'); ?>
<div class="most-read hero__most-read"> <div class="most-read hero__most-read">
<div class="most-read__inner"> <div class="most-read__inner">
<p class="most-read__title subtitle-20">Самое читаемое</p> <p class="most-read__title subtitle-20">Главное сегодня</p>
<div class="most-read__links"> <div class="most-read__links">
<?php get_template_part('partials/most-read-posts'); ?> <?php get_template_part('partials/most-read-posts'); ?>
</div> </div>

View File

@@ -16,7 +16,7 @@
<?php if (is_front_page()) : ?> <?php if (is_front_page()) : ?>
<div class="most-read mobile"> <div class="most-read mobile">
<div class="most-read__inner"> <div class="most-read__inner">
<p class="most-read__title subtitle-20">Самое читаемое</p> <p class="most-read__title subtitle-20">Главное сегодня</p>
<div class="most-read__links"> <div class="most-read__links">
<?php get_template_part('partials/most-read-posts'); ?> <?php get_template_part('partials/most-read-posts'); ?>
</div> </div>

View File

@@ -1,7 +1,7 @@
<?php if (!is_front_page()) : ?> <?php if (!is_front_page()) : ?>
<div class="most-read content-right__most-read"> <div class="most-read content-right__most-read">
<div class="most-read__inner"> <div class="most-read__inner">
<p class="most-read__title subtitle-20">Самое читаемое</p> <p class="most-read__title subtitle-20">Главное сегодня</p>
<div class="most-read__links"> <div class="most-read__links">
<?php get_template_part('partials/most-read-posts'); ?> <?php get_template_part('partials/most-read-posts'); ?>
</div> </div>

View File

@@ -43,7 +43,7 @@ $categoryLink = get_queried_object()->slug;
</div>--> </div>-->
</div> </div>
<a href="/events" class="articles-preview__show-next">Все мероприятия</a> <a href="/events/" class="articles-preview__show-next">Все мероприятия</a>
<div class="articles__spacer-container"> <div class="articles__spacer-container">
<div class="articles__spacer"></div> <div class="articles__spacer"></div>
<div class="articles__spacer"></div> <div class="articles__spacer"></div>