social share buttons

<div class="social-share-btn">
		<div id="fb-root"></div>
<script>(function(d, s, id) {
 var js, fjs = d.getElementsByTagName(s)[0];
 if (d.getElementById(id)) return;
 js = d.createElement(s); js.id = id;
 js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0";
 fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-share-button" data-href="<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];?>" data-layout="button_count"></div>



<a href="<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];?>" data-count="horizontal" class="twitter-share-button">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>


<!-- Place this tag in your head or just before your close body tag. -->
<script src="https://apis.google.com/js/platform.js" async defer></script>
<!-- Place this tag where you want the share button to render. -->
<div class="g-plus" data-action="share" data-annotation="bubble" data-href="<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];?>"></div>


<script src="//platform.linkedin.com/in.js" type="text/javascript">
 lang: en_US
</script>
<script type="IN/Share" data-counter="right" data-url="<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];?>"></script>

    </div>

create child page emplate dynamically in wordpress

Mixing some functions from here and here I wrote the code below in my functions.php:

// child page
function the_slug($pageID) { // Is there any other way to get the parent page slug?

	$post_data = get_post($pageID, ARRAY_A);
	$slug = $post_data['post_name'];
	return $slug;
}

function child_page_template(){
	global $post;
	$parent_page_slug = the_slug($post->post_parent);
	$page_template = 'page-'. $parent_page_slug . '-child.php'; //name it on your own
	$parents = get_post_ancestors($post->ID); // if is child
	if($parents){update_post_meta($post->ID,'_wp_page_template',$page_template);}

}

add_action('save_post','child_page_template'); 

Now, every time a child page is created or updated it will have as page template a file named “page-parentslug-child.php.

for example:
‘PARENT’ => page-slug.php (default)
‘parent’> ‘CHILD’ => page-‘PARENTSLUG’-child.php
‘parent’> ‘child’> ‘GRANDCHILD’ => page-‘CHILDSLUG’-child.php
‘parent’> ‘child’> ‘grandchild’ > ‘GRAND-GRANDCHILD’ => page-‘GRANDCHILDSLUG’-child.php (…) and so on.

That it

show custom post type with taxonomoy in template file in wordpress

<div class="caamera_loop">	
				<?php $categories = get_categories("taxonomy=cameracat");
				foreach ($categories as $category) :
				?>
				<div class="caamera_single">
					
					<div class="caamera_single_head">
						<?php echo $category->name;?>
					</div>

					<div class="caamera_single_li">
						<ul class="services_ul" id="<?php echo $category->term_id;?>" >
					<?php
					$args = array(
						'post_type' => 'camera',
						'posts_per_page' => -1,
						'tax_query' => array(
							array(
								'taxonomy' => 'cameracat',
								'field' => 'slug',
								'terms' => $category->slug
							)
						)
					);
					query_posts( $args );

					// The Loop
					$i=0;
					while ( have_posts() ) : the_post(); ?>	
							<li class="single-camera">
							<div class="single-camera-pic">
								<?php
									if ( has_post_thumbnail() ) {
										the_post_thumbnail();
									} 
								?>
							</div>	
							<a href="<?php echo the_permalink();?>">
							<?php the_title(); ?>
							</a>
							</li>
						<?php 
						$i++;
						endwhile;
							// Reset Query
							wp_reset_query();
						?>							
						</ul>
					</div>					
				</div>
				<?php endforeach; ?>
			</div>

show custom posts with category slug

<ul class="strategy_section" >
				<?php
				$args = array(
					'post_type' => 'strategy',
					'posts_per_page' => -1,
					//'cat_name' => $category->name,
					'tax_query' => array(
						array(
							'taxonomy' => 'service_cat',
							'field' => 'slug',
							'terms' => $category->slug
						)
					)
				);
				query_posts( $args );

				// The Loop
				$i=0;
				while ( have_posts() ) : the_post(); ?>	
						<li class="<?=$i>1?'hide_serv_li':''?>">
						<a href="<?php echo the_permalink();?>">
						<?php the_title(); ?>
						</a>
						</li>
					<?php 
					$i++;
					endwhile;
						// Reset Query
						wp_reset_query();
					?>							
					</ul>

show custom posts in theme templates in wordpress

<?php	
				$my_query = new WP_Query('post_type=approach&posts_per_page=-1&orderby=date&order=ASC');
				while ($my_query->have_posts()) : $my_query->the_post(); ?>				
				
				<div class="single_approach">
					<div class="approach_icon">
						<?php echo get_the_post_thumbnail( get_the_ID() ); ?>
					</div>
					<div class="approach_content">
						<h2 class="approach_title"><?php the_title(); ?></h2>
						<div class="approach_description">					 
								<?php the_excerpt(); ?>					
						</div>
						
					</div>
					<div class="approach_readmore">
						
							Read More
						
						</div>
				</div>	
			<?php 
			endwhile;  
			wp_reset_query();
			?>

wordpress numeric pagination for category page

function blog_pagination($pages = '', $range = 2)
{  
     $showitems = ($range * 2)+1;  

     global $paged;
     if(empty($paged)) $paged = 1;

     if($pages == '')
     {
         global $wp_query;
         $pages = $wp_query->max_num_pages;
         if(!$pages)
         {
             $pages = 1;
         }
     }   

     if(1 != $pages)
     {
         echo "<div class='pagination'>";
         if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='?".get_pagenum_link(1)."'>&laquo;</a>";

         for ($i=1; $i <= $pages; $i++)
         {
             if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
             {
				 
				  echo ($paged == $i)? "<span class='current'>".$i."</span>":"<a href='?page=".$i."' class='inactive' >".$i."</a>";
             }
         }

         if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) 
		 
 
		 echo "<a href='?page=".$pages."'>&raquo;</a>";
         echo "</div>\n";
     }
}

$i=1;
global $paged;
$paged = (get_query_var('page')) ? get_query_var('page') : 1;

$args = array( 'category_name' => $cat , 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 20, 'paged' => $paged , 'orderby' =>'date','order' => 'DESC' );

 $additional_loop = new WP_Query($args);
 while ($additional_loop->have_posts()) : $additional_loop->the_post();
 ?>
 
 <div class="single_posts_thumb">
	<?php if(has_post_thumbnail()){?>
	<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
	<?php } else { ?>
	<a href="<?php the_permalink(); ?>"><img src="<?php bloginfo('template_url'); ?>/images/blog_dflt_thumb.png"/></a>
	<?php } ?>
</div> 

<?php
$i++;
endwhile;
wp_reset_postdata();

?>

<?php	blog_pagination($additional_loop->max_num_pages, 3); ?>