Skip to main content
14 events
when toggle format what by license comment
Dec 4, 2020 at 13:46 comment added Drew Baker @Sebastian is correct new versions of WP seems to not allow permalinks for drafts, even after they are published.
Jun 15, 2020 at 8:21 history edited CommunityBot
Commonmark migration
Feb 24, 2016 at 16:49 comment added Sebastian Yes, even when a post is published and then afterwards set to "pending" or "draft", my WP 4.2 removes the "post_name" value (slug) from the database for that post. So I am just setting this value via the direct database call (UPDATE wp_wms_posts SET ...) ;-) Thank you very much for your help - much appreciated!!
Feb 24, 2016 at 12:51 comment added Adam Is that once you have already saved it to published at least once? I imagine there would be several scenarions that we would need to cater for. You can probably hook into change_post_status instead of using a wpdb call directly. Interesting find though!
Feb 24, 2016 at 10:01 comment added Sebastian I found another problem: when setting posts to status "pending" or "draft" using the WordPress function 'change_post_status' - it removes the "post_name" value from the database. Thus, there is no slug anymore... I solved the problem by setting the post_status manually with a db-script: $wpdb->query("UPDATE wp_wms_posts SET post_status = 'pending' WHERE ID = $post->ID;");
Feb 22, 2016 at 9:40 history edited Adam CC BY-SA 3.0
added 26 characters in body
Feb 22, 2016 at 9:19 comment added Sebastian I think I found a solution to the problem of private posts being unaccessible to admins / logged in users. See my update above.
Feb 21, 2016 at 4:22 comment added Adam Glad it works, to some degree. My example above is not without its caveats, one of which you probably found concerning private posts. It is however a means to get you started in the right direction. Likely we need some further logic to maintain private post functionality. If I get some time today I'll play around with it and try and reproduce the bug and work out a fix.
Feb 20, 2016 at 18:29 comment added Sebastian Update: I just noticed a problem when viewing posts in status private. They should of course not be visible to non logged in users (that part works) - however, they are not visible anymore to logged in users!
Feb 20, 2016 at 17:47 comment added Sebastian Thank you soooo much! This worked perfectly!! Which, in a way, I find strange - since I feel I was already there with a very similar approach (which I found at the source / link above). I've updated my post with the code I was using before, which did not work (gave me a 404 when I viewed a page as a non logged in user). T H A N K S again!!
Feb 20, 2016 at 17:46 vote accept Sebastian
Feb 20, 2016 at 9:14 history edited Adam CC BY-SA 3.0
deleted 131 characters in body
Feb 19, 2016 at 12:20 history edited Adam CC BY-SA 3.0
added 98 characters in body
Feb 19, 2016 at 12:12 history answered Adam CC BY-SA 3.0