gabaozin Posted January 13, 2011 Share Posted January 13, 2011 Hello, Thanks for reading this. I'm working on a project where the homepage should be a Today's Deal and I'm using the Auto delete posts plugin to move the Today's Deal to the "Previous Deals" Category, after 24 hours. My task is to automatically redirect the homepage to the only post in Today's Deal Category, which will have different permalinks everyday. I'm querring the post with: <?php query_posts("cat=41&showposts=1"); ?> And I tried redirecting to the result with: <?php $url = the_permalink(); header("Location: $url"); ?> just after query_posts... but no success. I tried several other things too, apart from searching the web a lot before posting here. Help! Anyone? Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/224333-automatic-redirect-to-only-post-after-a-query_post-with-showposts1-in-wordpress/ Share on other sites More sharing options...
QuickOldCar Posted January 13, 2011 Share Posted January 13, 2011 When you say no success what does or does not happen. Are you doing a check to see if there is at least 1 or more posts after your query? So you are saying that the home page will always just display that one post query and never a posts loop...correct? If so try this: <?php $url = the_permalink(); echo "<meta http-equiv='refresh' content='0;url=$url'>";//0 is instant, if want delay increase number exit();//added this for good measure in case more code was to execute ?> Quote Link to comment https://forums.phpfreaks.com/topic/224333-automatic-redirect-to-only-post-after-a-query_post-with-showposts1-in-wordpress/#findComment-1159041 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.