Archive for the ‘WordPress’ Category


function woocommerce_yoast_fix_style() {
    echo '
    .widefat * {
    word-wrap: normal !important;
    }
     ';
}
add_action('admin_head', 'woocommerce_yoast_fix_style');

//Returns All Term Items for "my_taxonomy"
$term_list = wp_get_post_terms($post->ID, 'my_taxonomy', array("fields" => "all"));
print_r($term_list);

//Returns Array of Term Names for "my_taxonomy"
$term_list = wp_get_post_terms($post->ID, 'my_taxonomy', array("fields" => "names"));
print_r($term_list);

//Returns Array of Term ID's for "my_taxonomy"
$term_list = wp_get_post_terms($post->ID, 'my_taxonomy', array("fields" => "ids"));
print_r($term_list);

Pagination in WordPress

Posted: January 31, 2015 in All Category, WordPress

 $args = array(
 'post_type' => 'wp_post',
 'paged' => $paged,
 'posts_per_page' => 2);

 $agent_selection = new WP_Query($args);

 pagination($agent_selection->max_num_pages, $range = 2); 

function 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 '<ul class="pagination pagination_nojax">';
 echo "<li class=\"roundleft\"><a href='".get_pagenum_link($paged - 1)."'><i class=\"fa fa-angle-left\"></i></a></li>";
 
 for ($i=1; $i <= $pages; $i++)
 {
 if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
 {
 if ($paged == $i){
 print '<li class="active"><a href="'.get_pagenum_link($i).'" >'.$i.'</a><li>';
 }else{
 print '<li><a href="'.get_pagenum_link($i).'" >'.$i.'</a><li>';
 }
 }
 }
 
 $prev_page= get_pagenum_link($paged + 1);
 if ( ($paged +1) > $pages){
 $prev_page= get_pagenum_link($paged );
 }else{
 $prev_page= get_pagenum_link($paged + 1);
 }
 
 
 echo "<li class=\"roundright\"><a href='".$prev_page."'><i class=\"fa fa-angle-right\"></i></a><li></ul>";
 }
}