Monthly Archives: May 2015

Pagignation for custom post type

functions.php


/** pagination **/
function fruit_pagination($pages = '', $range = 5)
{
$fruit_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;
}
} echo '<div class="site-pagination">';
if(1 != $pages)
{

echo "<ul>";
if($paged > 2 && $paged > $range+1 && $fruit_showitems < $pages) echo "<li class='pagination-previous-all'><a href='".get_pagenum_link(1)."'><span class='sprite previous-all-icon'><<</span></a></li>";
if($paged > 1 && $fruit_showitems < $pages) echo "<li class='pagination-previous'><a href='".get_pagenum_link($paged - 1)."'><span class='sprite previous-icon'><</span></a></li>";
for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $fruit_showitems ))
{
echo ($paged == $i)? "<li class='active'><a href='#' >".$i."</a></li>":"<li><a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a></li>";
}
}
if ($paged < $pages && $fruit_showitems < $pages) echo "<li class='pagination-next'><a href='".get_pagenum_link($paged + 1)."'><span class='sprite next-icon'>></span></a></li>";
if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $fruit_showitems < $pages) echo "<li class='pagination-next-all'><a href='".get_pagenum_link($pages)."'><span class='sprite next-all-icon'>>></span></a></li>";
echo "</ul>\n";
}
echo '</div>';
}
/** End pagination **/

your_page_template.php


<?php
if (function_exists('fruit_pagination')) {
fruit_pagination($legal_ourteam->max_num_pages, '2');
}
?>

Add email header by theme options

functions.php


add_filter('wp_mail_from_name','custom_email_from_name');
function custom_email_from_name($emailname) {
$options = get_option( 'theme_options' );
// set a custom name for notifications
$emailname =  $options['email_title'];
return $emailname;
}

Password free login via mobile

Secure two-factor that people love to use: strong authentication without passwords or tokens; single sign on/off; magical user experience.

https://wordpress.org/plugins/wpclef/

YouTube, Vimeo, MP4/WebM and Image Lightbox Plugin

https://www.wonderplugin.com/wordpress-lightbox/

Use this css for hide plugin brand name:

#html5-watermark div {
display: none !important;
}

Scroll To DIV – Using Button ID

template-file.php


<button type="button" id="btnscrall" value="scrall">SCRALL</button>

default.js


jQuery("#btnscrall").click(function() {
jQuery('html, body').animate({
scrollTop: jQuery(".caseresult").offset().top
}, 2000);
});

Add Custom Column for Posts and Custom Post Types in backend

functions.php

Default for all avalable post types.


add_image_size('featured_preview', 55, 55, true);
// GET FEATURED IMAGE
function ST4_get_featured_image($post_ID) {
$post_thumbnail_id = get_post_thumbnail_id($post_ID);
if ($post_thumbnail_id) {
$post_thumbnail_img = wp_get_attachment_image_src($post_thumbnail_id, 'featured_preview');
return $post_thumbnail_img[0];
}
}
// ADD NEW COLUMN
function ST4_columns_head($defaults) {
$defaults['featured_image'] = 'Featured Image';
return $defaults;
}

// SHOW THE FEATURED IMAGE
function ST4_columns_content($column_name, $post_ID) {
if ($column_name == 'featured_image') {
$post_featured_image = ST4_get_featured_image($post_ID);
if ($post_featured_image) {
echo '<img src="' . $post_featured_image . '" />';
}
}
}
add_filter('manage_posts_columns', 'ST4_columns_head');
add_action('manage_posts_custom_column', 'ST4_columns_content', 10, 2);

If you want Create Custom Column for your  requirement so use this code (Use for Specific Post).


add_filter('manage_edit-portfolios_columns', 'add_new_portfolios_columns');
function add_new_portfolios_columns() {
$new_columns['cb'] = '<input type="checkbox" />';
$new_columns['title'] = _x('Name', 'column name');
$new_columns['featured_image'] = __('Images');
$new_columns['taxonomy-portfolio-categories'] = __('Portfolio Categories');
$new_columns['taxonomy-portfolio-tag'] = __('Portfolio Tag');
$new_columns['date'] = _x('Date', 'column name');
return $new_columns;
}
/*Featured Images*/
// GET FEATURED IMAGE
function portfolio_get_featured_image($post_ID) {
$post_thumbnail_id = get_post_thumbnail_id($post_ID);
if ($post_thumbnail_id) {
$post_thumbnail_img = wp_get_attachment_image_src($post_thumbnail_id, 'featured_preview');
return $post_thumbnail_img[0];
}
}
// SHOW THE FEATURED IMAGE
function portfolio_columns_content($column_name, $post_ID) {
if ($column_name == 'featured_image') {
$post_featured_image = portfolio_get_featured_image($post_ID);
if ($post_featured_image) {
echo '<img src="' . $post_featured_image . '" />';
}
}
}
// About WordPress Hooks
add_action('manage_posts_custom_column', 'portfolio_columns_content', 10, 2);

%d bloggers like this: