pagination - Modifying the_posts_pagination from within functions.php instead of template files
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 badges1 Answer
Reset to default 1Is 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.
- 微软为何仍在打造硬件 听纳德拉怎么说
- google tag manager - GTM custom template - not able to trigger callback from script - Stack Overflow
- r markdown - Rstudio custom traceback - Stack Overflow
- java.lang.NoClassDefFoundError: Could not initialize class org.apache.spark.SparkThrowableHelper$ - Stack Overflow
- apache spark - Can't save pyspark ML model :py4j.protocol.Py4JJavaError: An error occurred while calling o577.save. : ja
- swiftui - ShareLink with custom type produces error - Stack Overflow
- javascript - How can you use a React hook conditionally in a function component - Stack Overflow
- python - Custom font in a style sheet in matplotlib - Stack Overflow
- Flutter - individual bloc states - Stack Overflow
- tensorflow - Error when loading old .h5 file with latest Keras - Stack Overflow
- postgresql - How to divide two NUMERIC values and get a result that has the maximum number of digits the NUMERIC type supports?
- docker - Unable to Set Up Keycloak with Production Mode - Stack Overflow
- pytorch - how to get custom column in the model's forward() function when training with Huggingface Trainer? - Stack Ove
- Need to find a way to change a library (SO file) without reinstalling an application in Android 13 on rooted device. Permission
- reactjs - How to keep the modal open after navigating and returning from a certain screen in react native? - Stack Overflow
- ZeroMQ Subscriber in Rails Worker Fails to Receive Messages, but Works with QLStats - Stack Overflow
- sockets - PICO WMicropython websocket client can't send to PHP websocket properly - Stack Overflow