Ussing page_navi with WP_Query

I'm ussing in my site that code:

category-anuncios.php

    div class="listado-anuncios"
                ?php
                    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                 
                    $query=array("category_name"="anuncios","order"="ASC","posts_per_page"="1","page"=$paged);
                    $objAnuncio = new WP_Query($query);
                    if ($objAnuncio-have_posts()){
                        ?
                        ul
                            ?php
                            while($objAnuncio-have_posts()){
                                $objAnuncio-the_post();
                                ?
                                li
                                    ?php
the_title();
                                    ?
                                /li
                                ?php
                            }
                            ?
                        /ul
                        ?php
                        if (function_exists("wp_pagenavi")){wp_pagenavi(array("query"=$objAnuncio));}
                        wp_reset_postdata();
                    }           
                ?          
            /div      

I can see the content of my post well and show too the navigation...but, if I try to navigate to the second, third or other I have the error 404.

How can use that navigation with my custom query?

Edit:

Another way to test to fix the error:

Change the WP_Query for query_posts like that

global $wp_query;
                $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;    
                $categoria = $wp_query-query_vars["cat"];
                query_posts('cat='.$categoria.'posts_per_page=1paged='.$paged);

But I've the same result: error 404

Topic plugin-wp-pagenavi navigation Wordpress

Category Web


Just work including that code in the functions file:

function mod_query($query){
    $entradas = get_category_by_slug('anuncios');    
    if ((!is_admin() && $query->is_main_query())){
        $query->set('posts_per_page',"2");
        $query->set('cat','8');
    }
}
add_action('pre_get_posts','mod_query');

The file to show the content of the category is a normal file (without extra configuration)

Thanks to @Pieter Groosen for the orientation.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.