Asapcorp
Member
Posted 3 years ago #
Hi,
am trying to get popular posts from the db
function get_popularposts{
// other code ....
foreach($myposts as $post) {
$thePostID = $post->ID;
$sLink = get_permalink($post->ID);
//echo get_permalink($post->ID);
// $sLink = get_permalink($thePostID);
// other code ....
}
}
Here $thePostID returns the correct post id. $sLink returns the domain name instead of post url. It returns the correct url in Localhost (in my local system). However, it returns the domain name when I upload it into web.
Asapcorp
Member
Posted 3 years ago #
can someone help on this please ?
thanks
Without seeing more of the code it could be any number of things...
Sounds like you're having loop problems...
Are you creating a new WP Query for the popular posts list?
Asapcorp
Member
Posted 3 years ago #
I believe I am not getting any loop problems. I am getting the post id correctly
echo $thePostID;
the above code prints the correct post id. I am getting the content from the post correctly. am getting the custom fields correctly. The only issue is with the links.
Asapcorp
Member
Posted 3 years ago #
also it works great in my local machine .. am getting the correct permalinks. Only on web, it doesn't return the correct permalinks url.