admin管理员组

文章数量:1026989

I know that using a function like the following (in functions.php) allows me to customize pagination options:

function custom_theme_pagination(){
    global $wp_query; 
    echo paginate_links();
}

... provided that the theme file then contains <?php custom_theme_pagination(); ?> wherever I want the pagination to show.

However, what I would like to achieve is control how any instance of <?php the_posts_pagination(); ?> will appear without having to create a custom function and then replacing the code in my theme files with <?php custom_theme_pagination(); ?> instead of <?php the_posts_pagination(); ?>.

Is it possible to modify or give arguments for the original <?php the_posts_pagination(); ?> -- in the functions.php file, not in theme files -- without wrapping it in a custom function? If yes, can you explain in detail how that works, please? I ask for details because I want to learn how to do this with pagination and be able to use what I learned for other similar matters that might come up.

Thanks in advance.

I know that using a function like the following (in functions.php) allows me to customize pagination options:

function custom_theme_pagination(){
    global $wp_query; 
    echo paginate_links();
}

... provided that the theme file then contains <?php custom_theme_pagination(); ?> wherever I want the pagination to show.

However, what I would like to achieve is control how any instance of <?php the_posts_pagination(); ?> will appear without having to create a custom function and then replacing the code in my theme files with <?php custom_theme_pagination(); ?> instead of <?php the_posts_pagination(); ?>.

Is it possible to modify or give arguments for the original <?php the_posts_pagination(); ?> -- in the functions.php file, not in theme files -- without wrapping it in a custom function? If yes, can you explain in detail how that works, please? I ask for details because I want to learn how to do this with pagination and be able to use what I learned for other similar matters that might come up.

Thanks in advance.

Share Improve this question asked Mar 21, 2019 at 10:44 jsmodjsmod 5013 silver badges18 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Is it possible to modify or give arguments for the original -- in the functions.php file, not in theme files -- without wrapping it in a custom function?

No.

There are no hooks that allow modifying the arguments to this function. Wrapping it in your own function is the way to go. There's nothing inherently smarter or superior or more smarter about using filters.

I know that using a function like the following (in functions.php) allows me to customize pagination options:

function custom_theme_pagination(){
    global $wp_query; 
    echo paginate_links();
}

... provided that the theme file then contains <?php custom_theme_pagination(); ?> wherever I want the pagination to show.

However, what I would like to achieve is control how any instance of <?php the_posts_pagination(); ?> will appear without having to create a custom function and then replacing the code in my theme files with <?php custom_theme_pagination(); ?> instead of <?php the_posts_pagination(); ?>.

Is it possible to modify or give arguments for the original <?php the_posts_pagination(); ?> -- in the functions.php file, not in theme files -- without wrapping it in a custom function? If yes, can you explain in detail how that works, please? I ask for details because I want to learn how to do this with pagination and be able to use what I learned for other similar matters that might come up.

Thanks in advance.

I know that using a function like the following (in functions.php) allows me to customize pagination options:

function custom_theme_pagination(){
    global $wp_query; 
    echo paginate_links();
}

... provided that the theme file then contains <?php custom_theme_pagination(); ?> wherever I want the pagination to show.

However, what I would like to achieve is control how any instance of <?php the_posts_pagination(); ?> will appear without having to create a custom function and then replacing the code in my theme files with <?php custom_theme_pagination(); ?> instead of <?php the_posts_pagination(); ?>.

Is it possible to modify or give arguments for the original <?php the_posts_pagination(); ?> -- in the functions.php file, not in theme files -- without wrapping it in a custom function? If yes, can you explain in detail how that works, please? I ask for details because I want to learn how to do this with pagination and be able to use what I learned for other similar matters that might come up.

Thanks in advance.

Share Improve this question asked Mar 21, 2019 at 10:44 jsmodjsmod 5013 silver badges18 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Is it possible to modify or give arguments for the original -- in the functions.php file, not in theme files -- without wrapping it in a custom function?

No.

There are no hooks that allow modifying the arguments to this function. Wrapping it in your own function is the way to go. There's nothing inherently smarter or superior or more smarter about using filters.

本文标签: paginationModifying thepostspagination from within functionsphp instead of template files