changed orgization
This commit is contained in:
35
header.php
35
header.php
@ -17,6 +17,41 @@
|
||||
<meta charset="<?php bloginfo( 'charset' ); ?>">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="profile" href="https://gmpg.org/xfn/11">
|
||||
<?php
|
||||
$author_id = get_option('sophia_after_dark_home_og_user', 1); // Default to user ID 1 if not set
|
||||
|
||||
$author_bio = get_the_author_meta('description', $author_id);
|
||||
|
||||
if (is_front_page()) {
|
||||
$home_og_image = get_option('sophia_after_dark_home_og_image');
|
||||
if ($home_og_image) {
|
||||
echo '<meta property="og:image" content="' . esc_url($home_og_image) . '" />' . "\n";
|
||||
}
|
||||
|
||||
echo '<meta property="og:title" content="' . esc_attr(get_bloginfo('name') . ' - ' . get_bloginfo('description')) . '" />' . "\n";
|
||||
echo '<meta property="og:description" content="' . esc_attr($author_bio) . '" />' . "\n";
|
||||
echo '<meta property="og:url" content="' . esc_url(home_url('/')) . '" />' . "\n";
|
||||
} elseif (is_single() || is_page()) {
|
||||
global $post;
|
||||
if (has_post_thumbnail($post->ID)) {
|
||||
$thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'og-image-size');
|
||||
if ($thumbnail) {
|
||||
echo '<meta property="og:image" content="' . esc_url($thumbnail[0]) . '" />' . "\n";
|
||||
// Uncomment and adjust the following lines if needed
|
||||
// $thumbnail_url = esc_url($thumbnail[0]);
|
||||
// $thumbnail_parts = pathinfo($thumbnail_url);
|
||||
// $thumbnail_new_url = $thumbnail_parts['dirname'] . '/' . $thumbnail_parts['filename'] . '-1536x878.' . $thumbnail_parts['extension'];
|
||||
// echo '<meta property="og:image" content="' . $thumbnail_new_url . '" />' . "\n";
|
||||
}
|
||||
} else {
|
||||
echo '<meta property="og:image" content="' . esc_url(get_template_directory_uri() . '/assets/images/default-og-image.webp') . '" />' . "\n";
|
||||
}
|
||||
|
||||
echo '<meta property="og:title" content="' . esc_attr(get_the_title()) . '" />' . "\n";
|
||||
echo '<meta property="og:description" content="' . esc_attr(get_the_excerpt()) . '" />' . "\n";
|
||||
echo '<meta property="og:url" content="' . esc_url(get_permalink()) . '" />' . "\n";
|
||||
}
|
||||
?>
|
||||
<?php wp_head(); ?>
|
||||
</head>
|
||||
|
||||
|
Reference in New Issue
Block a user