';
}
}
add_action( 'wp_head', 'madd_magazine_pingback_header' );
function maddwp_pagination()
{
global $wp_query;
$big = 999999999;
echo paginate_links(array(
'base' => str_replace($big, '%#%', get_pagenum_link($big)),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'total' => $wp_query->max_num_pages,
'prev_text' => '←',
'next_text' => '→'
));
}
add_action('init', 'maddwp_pagination');
add_action( 'add_meta_boxes', 'slide_post_box' );
add_action( 'save_post', 'slide_post_save_postdata' );
function slide_post_box() {
add_meta_box(
'slider-post-id',
'Show In Slider',
'slide_post_callback',
'post',
'side',
'default'
);
}
function slide_post_callback($post)
{
wp_nonce_field( 'slide_post_field_nonce', 'slide_post_noncename' );
$saved = get_post_meta( $post->ID, 'home_slide_post', true);
if( !$saved )
$saved = 'default';
$fields = array(
'yes' => __('Yes', 'madd-magazine'),
'default' => __('No', 'madd-magazine'),
);
foreach($fields as $key => $label)
{
printf(
''.
'
',
esc_attr($key),
esc_html($label),
checked($saved, $key, false)
);
}
}
function slide_post_save_postdata( $post_id )
{
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
if ( isset($_POST['slide_post_noncename']) && !wp_verify_nonce( $_POST['slide_post_noncename'], 'slide_post_field_nonce' ) )
return;
if ( isset($_POST['home_slide_post']) && $_POST['home_slide_post'] != "" ){
update_post_meta( $post_id, 'home_slide_post', $_POST['home_slide_post'] );
}
}
function category_posts_pagination( $query )
{
if ( is_category() && $query->is_main_query() )
{
$default_posts_per_page = get_option( 'posts_per_page' );
$query->query_vars['posts_per_page'] = $default_posts_per_page + 1;
return;
}
}
add_action( 'pre_get_posts', 'category_posts_pagination', 1 );