Cách fix lỗi query posts trong plugin wp-pagenavi
If you use the plugin WP-PageNavi then make you will get an error when creating a new query in addition to the main loop in wordpress right? the number of pages it does not work properly, it is only the first page only.
Here’s how to make it work properly with some of it.
You copy the code below and paste it into your functions.php file dental
function curPageURL() {
$pageURL = 'http';
//check what if its secure or not
if ($_SERVER["HTTPS"] == "on") {
$pageURL .= "s";
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_
SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
$urlEnd = substr($pageURL, -3);
$page = str_replace("/", "", $urlEnd);
return $page;
}
code on’m not too hard to understand? it is used to filter out some of your current page. When you query a new loop in wordpress, you write the following structure
query_posts('cat=7,8,12,13,15&paged='.curPageURL());
important issue is that & paged = ‘. curPageURL (), it will take you to the correct location of your current page. Also several other parameters you add depending on the purpose of your home.
Is quite strong in the wordpress plugin, this error is very common, but very little dairy material errors.
If you copy my post, please remember to link the source to me.
This article is useful for you, press like on my help, encourage writing.