I'm trying to create a box with Google Plus comments in my WordPress blog. My blog migrated from http to https in jan/2016 so I want to call the comment box with different permalink if the post date in before the migration day.
This is the original G+ comment box:
<div class="g-comments"
data-href="<?php the_permalink(); ?>"
data-width="700"
data-first_party_property="BLOGGER"
data-view_type="FILTERED_POSTMOD">
</div>
I'm using Studiopress Genesis, the G+ code is placed in the loop before original WP comments with Genesis Simple Hooks. And this is what I wrote and it appears before content. How can I move from echo to return? Any precious help?
<?php
$permalink = get_permalink();
$now = time();
$compare_time = mktime(0, 0, 0, 1, 1, 2016);
$post_time = get_post_time('U');
$url03 = str_replace('https://', 'http://', $permalink );
if ($post_time < $compare_time) {
echo '<div class="g-comments" data-href="';
echo $url03 . '"';
echo ' data-width="700" ';
echo 'data-first_party_property="BLOGGER" ';
echo 'data-view_type="FILTERED_POSTMOD">';
echo '</div> ';
}
else {
echo '<div class="g-comments" data-href="';
echo the_permalink() . '"';
echo ' data-width="700" ';
echo 'data-first_party_property="BLOGGER" ';
echo 'data-view_type="FILTERED_POSTMOD">';
echo '</div> ';
}
?>