Shortcode function – replacing echo with return – need help
-
Hello, I’m new to writing WP plugins and after I wrote this code, I saw that the code is executed before the content of the page. Now I know I should had used return instead of echo. Any help how can I change the code? I am a real php beginner ??
<?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://', 'https://', $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> '; } ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Shortcode function – replacing echo with return – need help’ is closed to new replies.