Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Open Graph meta tags for archive pages. #13137

Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions functions.opengraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@ function jetpack_og_tags() {
$tags['profile:first_name'] = get_the_author_meta( 'first_name', $author->ID );
$tags['profile:last_name'] = get_the_author_meta( 'last_name', $author->ID );
}
} elseif ( is_archive() ) {
$tags['og:type'] = 'website';
jeherve marked this conversation as resolved.
Show resolved Hide resolved
jeherve marked this conversation as resolved.
Show resolved Hide resolved
$tags['og:title'] = wp_get_document_title();
$tags['og:site_name'] = get_bloginfo( 'name' );

$archive = get_queried_object();
if ( ! empty( $archive ) ) {
if ( is_category() || is_tag() || is_tax() ) {
$tags['og:url'] = get_term_link( $archive->term_id, $archive->$taxonomy );
jeherve marked this conversation as resolved.
Show resolved Hide resolved
$tags['og:description'] = $archive->description;
jeherve marked this conversation as resolved.
Show resolved Hide resolved
} elseif ( is_post_type_archive() ) {
$tags['og:url'] = get_post_type_archive_link( $archive->name );
$tags['og:description'] = $archive->description;
}
} else { // for date archives and future-proofing
$tags['og:url'] = home_url( '/' );
jeherve marked this conversation as resolved.
Show resolved Hide resolved
$tags['og:description'] = get_bloginfo( 'description' );
}
} elseif ( is_singular() ) {
global $post;
$data = $post; // so that we don't accidentally explode the global.
Expand Down