I created custom taxonomy and registered it with "Pages" with the following code

//hook into the init action and call create_book_taxonomies when it fires
add_action( 'init', 'create_Offer_Categorys_hierarchical_taxonomy', 0 );

//create a custom taxonomy name it Offer Categorys for your posts

function create_Offer_Categorys_hierarchical_taxonomy() {

// Add new taxonomy, make it hierarchical like categories
//first do the translations part for GUI

  $labels = array(
    'name' => _x( 'Offer Category', 'offer Categories general name' ),
    'singular_name' => _x( 'Offer Category', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Offer Category' ),
    'all_items' => __( 'All Offer Categorys' ),
    'parent_item' => __( 'Parent Offer Category' ),
    'parent_item_colon' => __( 'Parent Offer Category:' ),
    'edit_item' => __( 'Edit Offer Category' ), 
    'update_item' => __( 'Update Offer Category' ),
    'add_new_item' => __( 'Add New Offer Category' ),
    'new_item_name' => __( 'New Offer Category Name' ),
    'menu_name' => __( 'Offer Category' ),

// Now register the taxonomy

  register_taxonomy('offer-category',array('page'), array(
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'show_admin_column' => true,
    'query_var' => true,
    'exclude_from_search' => false,
    'rewrite' => array( 'slug' => 'offer-category' ),


Then I created a template file named taxonomy-offer-category.php

Issue is pagination is not working as it should be. After writing the code of pagination, paging url coming like this '/offer-category/automobile/page/2', etc

but this page is giving error (404) but when I manually hit url like

/offer-category/automobile?page=2 then this gives the result.I dont know whats the issue. below is the code for pagination

$paged = (get_query_var('page')) ? get_query_var('page') : 1;
// echo $paged; 
$args = array(
    'post_type' => 'page',
        'paged'    => $paged,
        'posts_per_page' => '1',        
    'tax_query' => array(       
        array(  'taxonomy' => 'offer-category',
            'field'    => 'id',
            'terms'    => $term_id

//$page_args=array('post_type' => 'page');
$query = new WP_Query($args);

$big = 999999999; // need an unlikely integer
                $links = paginate_links( array(

                    'current' => max( 1, get_query_var('page') ),
                    'total' => $query->max_num_pages,
                    'prev_text'    => '<',
                    'next_text'    => '>',
                    'type' => 'array'
                ) );

I have tried all the possible answers of google like using format, using paged instead of page etc and this issue is a long time back issue and I dont know whether it is fixed or not. Can you guys please help me in that.


1 Answer 1


If your site is at the root of the domain (something like http://www.example.com), find the location / block inside the configuration file, and add the following line to it.

try_files $uri $uri/ /index.php?$args;

Here, Nginx checks for the existence of a file at the URL ($uri), then for a directory ($uri/). If it doesn’t find a directory or a file, it performs an internal redirect to /index.php passing the query string arguments as parameters.

It should look like this after the edits :

location / {
    index index.php index.html index.htm;
    try_files $uri $uri/ /index.php?$args;

If your site is in a subfolder (say /site), you’ll have to add an extra location /site/ block to your configuration file :

location /site/ {
    try_files $uri $uri/ /site/index.php?$args;

After you have finished making the changes in the configuration file, reload the nginx configuration by :

nginx -s reload

Wordpress’ pretty permalinks should work fine now.

I found this answer here And here are some other helpful likns-

  1. https://codex.wordpress.org/Nginx
  2. http://www.lowendguide.com/3/webservers/wordpress-permalinks-with-nginx/
  3. https://www.pmg.com/blog/a-mostly-complete-guide-to-the-wordpress-rewrite-api/
  • I have tried that but still not working, I tried with default permalink as well Commented Nov 2, 2016 at 8:19
  • Are you using Apache ** or **NGINX ? @BhuvneshGupta
    – CodeMascot
    Commented Nov 2, 2016 at 8:21
  • I am using NGINX Commented Nov 2, 2016 at 8:24
  • That's why it is not working. You need to manually modify the rewrite rule for NGINX.
    – CodeMascot
    Commented Nov 2, 2016 at 8:26
  • how and what to do for that? Commented Nov 2, 2016 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.