John Davidson

php - WP query is accessing posts from staging site, not main site

0 comments
Message:


I used WP Staging Pro to create a staging site and then move it to my live site. It looks ok but my queried posts are bringing up the posts in the staging directory. So here's my code for the query.


$legal_array = query_posts(array(
'cat' => 85,
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'order' => 'asc',
'orderby' => 'menu_order'
));

The post generates with https://mysite/staging/?p=3213 as the URL for the post instead of https://mysite/?p=3213 for the post. If I add a new post on the main site, it also shows up in the query and works fine. All of the posts migrated and the permalinks for the migrated posts are correct. I tried trashing all the staging posts, setting all the staging posts to Draft, using wp_reset_query();, wp_reset_postdata(); and resetting the array with $legal_array = [];. I also checked the wp_config.php file to see if anything was set to the staging URL and there was nothing.



My Answer:
> 'legal',
'posts_per_page' => 5
));

This code is querying posts from the 'legal' category and limiting the results to 5 posts per page. However, if the posts are still showing up from the staging site, it could be because the database connection is still pointing to the staging site's database.

To fix this issue, you can try updating the database connection settings in your wp-config.php file to point to the live site's database. Make sure to update the database name, username, password, and host to match the live site's database details.

Once you have updated the database connection settings, try running the query again and see if it now retrieves posts from the live site instead of the staging site.

Rate this post

3 of 5 based on 6529 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us