Tuesday, February 18, 2014

Pembuatan Halaman Pada Page di Wordpress

di sini yang mo aku bahas mengenai pembuatan paging di wordpress tetapi bukan paging untuk post, postmeta, kategori (yang sudah ada fasilitas pembuatan page di wordpress) tetapi pembuatan paging pada page yang menggunakan query sendiri.






 array(
                'relation' => 'AND',
               
                array(
                    'key' => 'user_role',
                    'value' => '1',
                    'compare' => '='
                )
            )     
);
$user_count_query = new WP_User_Query($count_args);
$user_count = $user_count_query->get_results();

// count the number of users found in the query
$total_users = $user_count ? count($user_count) : 1;

// grab the current page number and set to 1 if no page number is set
$page = isset($_GET['l']) ? $_GET['l'] : 1;

// how many users to show per page


// calculate the total number of pages.
$total_pages = 1;
$offset = $users_per_page * ($page - 1);
$total_pages = ceil($total_users / $users_per_page);
$query_string = $_SERVER['QUERY_STRING'];

// The $base variable stores the complete URL to our page, including the current page arg

// if in the admin, your base should be the admin URL + your page
//$base = site_url('search') . '?' . remove_query_arg('p', $query_string) . '%_%';

// if on the front end, your base is the current page
$base = site_url('employer-2/') . '?' . remove_query_arg('l', $query_string) . '%_%';
?>

$base, // the base URL, including query arg 'format' => '&l=%#%', // this defines the query parameter that will be used, in this case "p" 'prev_next' => true, 'prev_text' => __('« Previous'), // text for previous page 'next_text' => __('Next »'), // text for next page 'total' => $total_pages, // the total number of pages we have 'current' => $page, // the current page 'end_size' => 1, 'mid_size' => 1, 'type' => 'list', 'show_all' => false, 'behind_color' => 'dark', 'page_bkg' => 'bright', 'current_page_bkg' => 'cyan', 'enable_rounded' => true, 'alignment' => 'left', 'enable_gradients' => true, 'separator_text' => '...' )); echo $paginate_links; ?>

No comments:

Post a Comment

Terima kasih