Hello trusted developers,
On my blog www.linguaid.net/blog, my Google Plus profile is not showing at the bottom of any post. I have shared it ok in the Settings > Sharing. I have successfully done this on other blogs (e.g. http://www.lovefrance.info/learn-how-to-speak-french/) and don't know why it's not working here.
Here is a recent test post : http://www.linguaid.net/test-post-doesnt-mean-anything
FYI, I changed the profile photo of the google plus profile as it wasn't appropriate (I had a sideways blurry profile).
Please help!
Kind regards,
Hariprasad Vijayan answers:
Hello,
http://www.linguaid.net/blog is may be a category page. Others are blog posts, and the urls like http://www.lovefrance.info/learn-how-to-speak-french/ these are post's single page. Probably the plugin you are using enables Google Plus Share for single page. There might be an option/settings for enabling Google Plus Share for category. Please check the plugin setting once again.
Hariprasad.
Joss Frimond comments:
Hi Hariprasad,
No I mean't all the single posts in the blog category!
None of them have the share google profile on them.
Kind regards
Joss
Hariprasad Vijayan comments:
Hi Joss,
For clarification,
Just need a share on the bottom of www.linguaid.net/blog or need share on each post listed on www.linguaid.net/blog
Let me know
Thanks
Joss Frimond comments:
I need a share on each post listed. Every single one.
Hariprasad Vijayan comments:
Popular social share plugins have an option for enabling share button display location in its setting. I think there might be an option for enabling Google Plus Share for categories. Have you check settings?
Joss Frimond comments:
Hi Hariprasad,
Like I said, I'm NOT interested in sharing the category. The Google Profile is not showing on each blog post. That is what I want fixing.
Hariprasad Vijayan comments:
It is not about sharing category, it is just enabling post share on category page
Arnav Joy answers:
what is you are using to show it any plugin or any code?
Joss Frimond comments:
Hi Arnav,
It is the Jetpack plugin with the Google+ profile setting. By the way, I have WP 3.5.
Arnav Joy comments:
if you are doing it using jetpack plugin and have changed profile image then try to reconnect the jetpack from wordpress admin panel .
Joss Frimond comments:
I have disconnected and reconnected. Still nothing on: http://www.linguaid.net/test-post-doesnt-mean-anything
Dbranes answers:
Did you follow these steps?:
http://jetpack.me/support/google-plus/
Joss Frimond comments:
Yes
Dbranes comments:
I think this JetPack function is responsible for displaying the Google+ Profile:
function post_output_wrapper( $text = '', $echo = false ) {
global $post, $wp_current_filter;
if ( !is_single() )
return $text;
if ( get_post_type() != 'post' )
return $text;
$author = $this->information( $post->post_author );
if ( empty( $author ) )
return $text;
// Don't allow G+ to be added to the_content more than once (prevent infinite loops)
$done = false;
foreach ( $wp_current_filter as $filter ) {
if ( 'the_content' == $filter ) {
if ( $done )
return $text;
else
$done = true;
}
}
if ( !$this->show_on_this_post())
return $text;
$output = '';
$output .= '<div class="sharedaddy sd-block sd-social sd-gplus">';
$output .= '<h3 class="sd-title">' . __( 'Google+', 'jetpack' ) . '</h3>';
$output .= '<div class="sd-content">';
$output .= $this->byline( $post );
$output .= $this->follow_button( $post );
$output .= '</div>';
$output .= '</div>';
if ( $echo )
echo $text . $output;
else
return $text . $output;
}
So it seems to allow only <em>post </em> as post-type.
Is that true in your case?
Dbranes comments:
... or maybe the post author is not in the <em>gplus_authors </em> options.
You can check it with for example:
print_r( get_option( 'gplus_authors', array() ) );
and it should have an array key matching to the <em>$post->post_author</em> number.
Joss Frimond comments:
thanks Dbranes but I don't know what to do exactly? Can you be a bit more clear in your explanation?
Dbranes comments:
So I think the <strong>Google+</strong> Profile block will only display if:
- the post-type is <em>post</em>.
- <em>is_single()</em> is true
- the post author is defined in the <em>gplus_authors</em> option,
( i.e. if you have many authors writing posts on your blog, it will only show up on your own posts).
Joss Frimond comments:
where is the gplus_authors option? Are you looking at the Linguaid site?
Dbranes comments:
Try to add this into your <em>functions.php</em> file in the current theme directory:
add_action( 'wp_footer', function(){
$msg = 'Google+ profile';
if( array_key_exists( get_post( get_the_ID() )->post_author, get_option( 'gplus_authors', array() ) ) )
$msg .= ' - The current post author id matches the G+ author!';
echo $msg;
});
It should display messages in the footer, or maybye this:
add_action( 'wp_footer', function(){
printf( '<h1>debug:</h1>
<pre>post-author-id: %d </pre>
<pre>"gplus_authors" option: %s </pre>',
get_post( get_the_ID() )->post_author,
print_r( get_option( 'gplus_authors', array() ), TRUE )
);
});
if you need more debug informations. I assume you got PHP 5.3+.
Joss Frimond comments:
sorry, neither of those work - they both add code to the blog post
Dbranes comments:
can you be more specific? what kind of code?
Then please try this PHP 5.2 compatiable code in functions.php :
add_action( 'wp_footer', 'my_debug' );
function my_debug()
{
if( is_single() )
{
printf( '<hr/>post author id is %d', $GLOBALS['post']->post_author );
printf( '<hr/>gplus_authors option is <pre>%s</pre>', print_r( get_option( 'gplus_authors', array() ), TRUE ) );
}
}
Dbranes comments:
ps: did you remember the enclosing <em><?php ?></em> part ?
Joss Frimond comments:
Hi Dbranes,
Here is the content of the functions file. Can you add in your code please? For the moment, nothing works:
<?php
//Please note that this is a Parent Theme's functions.php file,
//any code you added will be gone if you do an upgrade.
//You are advised to use a child theme and add your own custom functions to the child theme's functions.php
//check WP_DEBUG
//Some plugins such as wpcu3er will disable PHP error reporting,
//therefore we must make sure it is turn on if WP_DEBUG is set to true.
if(defined('WP_DEBUG') == 1 || WP_DEBUG == true){
$error_setting = ini_get("display_errors");
if($error_setting == '0'){
ini_set('display_errors', '1');
}
}
//Check if PHP error reporting is enabled.
//if it is enabled, we will only ALLOW PHP fatal error, syntax error, parse errors etc to show only.
$php_error_setting = ini_get("display_errors");
if($php_error_setting == '1'){
//if you wnat to know what are these constants,
//reference to http://www.php.net/manual/en/errorfunc.constants.php
error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE & ~E_WARNING & ~ E_DEPRECATED & ~ E_USER_NOTICE);
}
// Required TrueThemes Framework - do not edit or theme will fail!
require_once(TEMPLATEPATH . '/truethemes_framework/truethemes_framework_init.php');
// Load translation text domain
load_theme_textdomain ('truethemes_localize');
?>
function my_debug()
{
if( is_single() )
{
printf( '<hr/>post author id is %d', $GLOBALS['post']->post_author );
printf( '<hr/>gplus_authors option is <pre>%s</pre>', print_r( get_option( 'gplus_authors', array() ), TRUE ) );
}
}
Dbranes comments:
ok, two things there:
- remove the ?> part
- copying code from this site can give you extra new lines
Here's a cleaned up version of your <em>functions.php</em> file:
[[LINK href="http://pastebin.com/yv3R93uQ"]]http://pastebin.com/yv3R93uQ[[/LINK]]
Joss Frimond comments:
Hi Dbranes,
Please see http://www.linguaid.net/test-post-doesnt-mean-anything for latest results. i copied the code for the pastebin link.
Thanks
Joss
Dbranes comments:
I constructed this fix that you can try out:
You can copy it from
[[LINK href="http://pastebin.com/AYGXPeqG"]]http://pastebin.com/AYGXPeqG[[/LINK]]
/**
* Fix for the missing GPlus Profile in JetPack
*
* @link: http://www.wpquestions.com/question/showLoggedIn/id/9130
*
*/
if( ! class_exists( 'GPlusProfileFix' ) )
{
add_action( 'init', array( 'GPlusProfileFix', 'get_instance' ) );
class GPlusProfileFix
{
static private $instance = NULL;
public function __construct()
{
add_filter( 'the_content', array( $this, 'the_content' ), 999, 1 );
}
static public function get_instance()
{
if ( NULL === self::$instance )
self::$instance = new self;
return self::$instance;
}
protected function information( $author ) {
$authors = get_option( 'gplus_authors', array() );
return ( empty( $authors[ $author ] ) ? array() : $authors[ $author ] );
}
protected function byline( $post ) {
$author = $this->information( $post->post_author );
$image = '<img src="' . esc_url( $author['profile_image'] ) . '?sz=40" alt="' . esc_attr( $author['name'] ) . '" width="20" height="20" align="absmiddle" /> ';
$byline = sprintf( '<a href="%1$s">%2$s</a><a rel="author" href="%1$s" class="gplus-profile">%3$s</a>', esc_url( $author['url'] ), $image, esc_html( $author['name'] ) );
return apply_filters( 'gplus_authorship_byline', $byline, $post );
}
protected function follow_button( $post ) {
$author = $this->information( $post->post_author );
return '<span class="g-follow-wrapper"><span class="g-follow" data-href="' . esc_url( $author['url'] ) . '" data-rel="author" data-height="15"></span></span>';
}
public function the_content( $content )
{
if( is_single() )
{
global $post;
$output = '';
$output .= '<div class="sharedaddy sd-block sd-social sd-gplus">';
$output .= '<h3 class="sd-title">' . __( 'Custom Google+', 'jetpack' ) . '</h3>';
$output .= '<div class="sd-content">';
$output .= $this->byline( $post );
$output .= $this->follow_button( $post );
$output .= '</div>';
$output .= '</div>';
$content .= $output;
}
return $content;
}
} // end class
}
Joss Frimond comments:
is this to paste over the whole functions.php page please?
Thanks
Dbranes comments:
Add this to your <em>functions.php</em> file.
(you can remove the previous debug code, it shows that the post author id matches gplus author info)
Joss Frimond comments:
Hi Dbranes,
I found out what the problem is. It is a conflict with the WMPL multi-lingual plugin. When I deactivate it, the google profile works.
The problem is, I really need the plugin as it is a bilingual site. I have changed themes but no luck.
Do you know how to resolve the conflict with an external plugin ?
Kind regards
Joss