Title: Sharing Archive Pages
Last modified: August 30, 2016

---

# Sharing Archive Pages

 *  Resolved [ameraz](https://wordpress.org/support/users/ameraz/)
 * (@ameraz)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/sharing-archive-pages/)
 * Is there anyway to enable sharing an Archive Page?
    Basically, posts will be 
   shareable only at `is_single()` so I’m looking for a way to be able to share 
   Posts Archive Pages at `is_home()`, `is_archive()`, `is_tag()` and so on.
 * [https://wordpress.org/plugins/jetpack/](https://wordpress.org/plugins/jetpack/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Brandon Kraft](https://wordpress.org/support/users/kraftbj/)
 * (@kraftbj)
 * Code Wrangler
 * [10 years, 8 months ago](https://wordpress.org/support/topic/sharing-archive-pages/#post-6494811)
 * Howdy,
 * While we allow individual posts to having sharing buttons on an archive page 
   when that is opted-in via Settings->Sharing, we do not have plans at this time
   to add sharing buttons to specifically share an archive page.
 * Cheers!
 *  Thread Starter [ameraz](https://wordpress.org/support/users/ameraz/)
 * (@ameraz)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/sharing-archive-pages/#post-6494824)
 * Thanks for your reply Brandon, look this is my site: [http://birchalltea.co.uk](http://birchalltea.co.uk)
   
   I really need this feature and although it’d be really cool if you were to include
   this at some point and make Jetpack flexible, what I really want to know is if
   there’s any way of hooking into the plugin to enable the printing of the buttons
   in archive pages, even if I’d have to put together my own Open Graph meta. Also,
   Im using Jetpack sharing feature for my products and the `og:type` is showing
   as `article` instead of `product`, might be worth taking a look into that.
 * Cheers!
 *  Plugin Author [Brandon Kraft](https://wordpress.org/support/users/kraftbj/)
 * (@kraftbj)
 * Code Wrangler
 * [10 years, 8 months ago](https://wordpress.org/support/topic/sharing-archive-pages/#post-6494828)
 * For the `og:type`, we don’t have any code to determine what the type should be,
   other than `is_singular()` should be `article`, `is_author` should be `profile`,
   etc).
 * You can filter our og tags to replace this as needed, e.g.
 *     ```
       add_filter( 'jetpack_open_graph_tags', 'custom_og_type' );
       function custom_og_type( $tags ) {
       $tags['og:type'] = "product";
       }
       ```
   
 * and adding a conditional, either within the function or to fire the `add_filter`
   as needed.
 * Back to the original issue, we’ll still output og tags on archive pages (though
   I’ve personally have had to dig into them to know if there are any notable things
   about them specifically).
 * Looking in `modules/sharedaddy/sharing-service.php`, I don’t think there’s a 
   way to hook it in as it is built now. The `sharing_display` function actually
   handles the output and it is set to return early if the global `$post` variable
   is empty and later in the code, it assumes there is a current post.
 * If I may, what’s the particular use case for sharing archive pages? Knowing why
   folks want certain features can help inform us as we look at future development.
 * Cheers!
 *  Thread Starter [ameraz](https://wordpress.org/support/users/ameraz/)
 * (@ameraz)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/sharing-archive-pages/#post-6494839)
 * Thanks again for coming back.
 * Well, just as the Open Graph suggests with the `og:type product.group` and having
   the resources to feed a Product Category – by that I mean having the `$term`‘
   s name, description and image, I think that providing the ability to share an
   Archive wether its Products or blog articles seems to be yet another interesting
   way of engaging with our audience.
 * Although not yet in practice, with the combination of these functions I’ve managed
   to get my Open Graph Meta ready:
 *     ```
       function getUrl() {
       	$url  = isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ? 'https' : 'http';
       	$url .= '://' . $_SERVER['SERVER_NAME'];
       	$url .= in_array( $_SERVER['SERVER_PORT'], array('80', '443') ) ? '' : ':' . $_SERVER['SERVER_PORT'];
       	$url .= $_SERVER['REQUEST_URI'];
       	return $url;
       }
   
       add_action('wp', __NAMESPACE__ . '\\pmt_remove_jetpack_og_meta');
       function pmt_remove_jetpack_og_meta() {
       	if (!is_admin()) {
       		if ( is_front_page() || is_home() || is_archive() || is_shop() || is_product_category() || (is_woocommerce() && is_tax()) ) {
       			add_filter( 'jetpack_enable_open_graph', '__return_false' );
       		}
       	}
       }
   
       add_action('wp_head', __NAMESPACE__ . '\\pmtScriptsLoaderHeader' );
       function pmtScriptsLoaderHeader() {
       	if (!is_admin()) {
       		// Set Facebook Open Graph Meta
       		$currentUrl = pmtGetUrl();
       		$fbMetaType = 'website';
       		$fbMetaTitle = get_bloginfo('name');
       		$fbMetaImg = get_template_directory_uri() . '/dist/images/Birchall-Tea.png';
       		$fbMetaDesc =  get_bloginfo('description');
   
       		if (is_front_page()) {
       			$fbMetaType = $fbMetaType;
       			$fbMetaTitle = $fbMetaTitle;
       			$fbMetaImg = $fbMetaImg;
       			$fbMetaDesc = $fbMetaDesc;
       		} elseif (is_shop()) {
       			$fbMetaType = 'product.group';
       			$fbMetaTitle = "Birchall's Tea Shop";
       			$shop = get_queried_object();
       			$thumbID = get_post_thumbnail_id($shop->ID);
       			$thumbSrc = wp_get_attachment_image_src( $thumbID, 'large');
       			$fbMetaImg = $thumbSrc[0];
       			$fbMetaDesc = $fbMetaDesc;
       		} elseif (is_product_category()) {
       			$fbMetaType = 'product.group';
       			$term = get_queried_object();
       			$tax_archive_title = get_field('tax_archive_title', $term);
       			$fbMetaTitle = $tax_archive_title;
       			$thumbID = get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true );
       			$thumbSrc = wp_get_attachment_image_src( $thumbID, 'large');
       			$fbMetaImg = $thumbSrc[0];
       			$fbMetaDesc = $term->description;
       		} elseif (is_woocommerce() && is_tax()) {
       			$fbMetaType = 'product.group';
       			$term = get_queried_object();
       			$tax_archive_title = get_field('tax_archive_title', $term);
       			$fbMetaTitle = $tax_archive_title;
       			$thumb = get_field('pa_thumb', $term);
       			$fbMetaImg = $thumb['sizes']['medium'];
       			$fbMetaDesc = $term->description;
       		} elseif (is_home()) {
       			$fbMetaType = 'website';
       			$blogPage = get_option('page_for_posts');
       			$blogPageObj = get_post($blogPage);
       			$fbMetaTitle = $blogPageObj->post_title;
       			$thumbID = get_post_thumbnail_id($blogPageObj->ID);
       			$thumbSrc = wp_get_attachment_image_src( $thumbID, 'large');
       			$fbMetaImg = $thumbSrc[0];
       			$fbMetaDesc = $blogPageObj->post_excerpt;
       		} elseif (is_archive()) {
       			$term = get_queried_object();
       			$fbMetaType = 'website';
       			$fbMetaTitle = $term->name;
       			$blogPage = get_option('page_for_posts');
       			$blogPageObj = get_post($blogPage);
       			$thumbID = get_post_thumbnail_id($blogPage->ID);
       			$thumbSrc = wp_get_attachment_image_src( $thumbID, 'large');
       			$fbMetaImg = $thumbSrc[0];
       			$fbMetaDesc = $fbMetaDesc;
       		}
   
       		if ( is_front_page() || is_shop() || is_product_category() || (is_woocommerce() && is_tax()) || is_home() || is_archive() ) { ?>
       			<!-- Facebook Open Graph Meta -->
       			<meta property="og:type" content="<?php echo $fbMetaType; ?>" />
       			<meta property="og:title" content="<?php echo $fbMetaTitle; ?>" />
       			<meta property="og:url" content="<?php echo $currentUrl; ?>" />
       			<meta property="og:description" content="<?php echo $fbMetaDesc; ?>" />
       			<meta property="og:site_name" content="<?php bloginfo('name'); ?>"/>
       			<meta property="og:image" content="<?php echo $fbMetaImg; ?>" />
       			<meta property="og:locale" content="en_GB">
       		<?php } ?>
       	}
       }
       ```
   
 * But even with this in my Archive Page I can’t get the buttons to be printed:
 *     ```
       if ( function_exists( 'sharing_display' ) ) {
            sharing_display( '', true );
       }
       ```
   
 *  Plugin Author [Brandon Kraft](https://wordpress.org/support/users/kraftbj/)
 * (@kraftbj)
 * Code Wrangler
 * [10 years, 8 months ago](https://wordpress.org/support/topic/sharing-archive-pages/#post-6494844)
 * > But even with this in my Archive Page I can’t get the buttons to be printed:
 * Correct. Currently, sharing display returns out early if it is the global `$POST`
   isn’t set: [https://github.com/Automattic/jetpack/blob/7c6700150c9ba685a3f988bcf24a9b59e2f7d4d1/modules/sharedaddy/sharing-service.php#L565-L566](https://github.com/Automattic/jetpack/blob/7c6700150c9ba685a3f988bcf24a9b59e2f7d4d1/modules/sharedaddy/sharing-service.php#L565-L566)
 * That function would need to be rewritten to account for the possibility of being
   included on archive pages (outside of individual posts, as they can be shown 
   as part of the excerpt or content of individual posts on an archive page), at
   least.
 * This is not something currently on the roadmap, but would be open to a PR.
 * Cheers,

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Sharing Archive Pages’ is closed to new replies.

 * ![](https://ps.w.org/jetpack/assets/icon.svg?rev=2819237)
 * [Jetpack - WP Security, Backup, Speed, & Growth](https://wordpress.org/plugins/jetpack/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/jetpack/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/jetpack/)
 * [Active Topics](https://wordpress.org/support/plugin/jetpack/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/jetpack/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/jetpack/reviews/)

## Tags

 * [sharing](https://wordpress.org/support/topic-tag/sharing/)

 * 5 replies
 * 2 participants
 * Last reply from: [Brandon Kraft](https://wordpress.org/support/users/kraftbj/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/sharing-archive-pages/#post-6494844)
 * Status: resolved