php - Calling a template part from a post -


i include iframe within post in wordpress. located inside content of post, meaning cannot in post template file, otherwise either before or after.

i'd add facebook plugin within posts:

<div id="socialwrap"><div class="fb-like" data-href="http://onlinearizonahomes.info"   data-send="true" data-width="450" data-show-faces="true" data-font="arial"></div></div> 

i thinking of calling template part within post <?php get_template_part( 'social' ); ?> cannot use php within post without plugin (i'd avoid using plugin this).

an alternative using javascript create html in post, seems unnecessary use of javascript.

what best way add html within wordpress post?

you can use shortcode.

add functions.php

function cudjex_fbshare( $atts, $content = null ) {      global $post;     $link = get_permalink($post->id);     return '<div id="socialwrap"><div class="fb-like" data-href="'.$link.'"   data-send="true" data-width="450" data-show-faces="true" data-font="arial"></div></div>';  }  add_shortcode('fb_share', 'cudjex_fbshare');  

usage : hello world, [fb_share] !


Comments

Popular posts from this blog

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -