Pagination in WordPress without plugin • WordPress Help

I already know that most of you who read me are addicted to Pagenavi that wonderful and well-built plugin that offers paging to our WordPress in a simple way.

Of course, just as we added pagination of comments without a plugin we can add pagination to our website without using Pagenavi or any other plugin, you just have to use an internal WordPress function that has been there since version 2.1 paginate_links and its possible parameters .

add_action ( 'wp_print_scripts' 'my_deregister_javascript' 100 ) ;

function my_deregister_javascript () {

wp_deregister_script ] ( 'contact-form-7' ) ;

}

We save the file and what we get is that the script Do not reload. You can disable (unregister) as many scripts as you want with this function.

Deactivating styles

For this example we are going to deactivate the style sheet of the WP-PageNavi plugin. And it is almost better to always add styles in your CSS, and not to take them from the plugins folders, sometimes update the plugins with CSS changes that can destroy your theme.

The first thing we have to do is open the file wp-pagenavi.php in a text editor and search wp_enqueue_style . What we found is this code:

And also this one:

What we are looking for is how Page Navi manages the styles. Once we have found it, we can close it (after analyzing it) and add the following to the file functions.php of your theme:

This disables the stylesheet of this plugin. As before, you can "unregister" how many styles you want with this feature.

Tips for improving the task

Now that we have disabled scripts and styles there are some things we can do to improve this technique or give it other uses:

  • Place the deactivated styles (or those you want to change) at the end of your stylesheet ( style.css ), adding some comment that identifies them, showing what they affect.
  • Combine several scripts in a single file and load them yourself.
  • Use conditional tags to fine-tune the control of loading styles and / or scripts.
  • If you turn off something, the / theme plugin may stop working properly. Most styles can be added to the style sheet of your theme so as not to load multiple style sheets. But with Javascript is different, with this type of code only combines several scripts if you really know what you are doing

NOTICE : this publication is two years or more ago. If it's a code or a plugin it might not work in the latest versions of WordPress, and if it's a news story it might be obsolete. Then do not say we have not warned you.

Loading …

That may also help you: