Skip to main content
21 events
when toggle format what by license comment
May 4, 2021 at 15:03 comment added MMK glad you figured this out.
May 4, 2021 at 14:56 comment added Daryl Roberts I have accepted your method as it was very helpful, but had to do something a little different to get it to work how I needed. My working code has been added to the OP
May 4, 2021 at 14:41 vote accept Daryl Roberts
Apr 28, 2021 at 14:05 comment added Daryl Roberts I have added my updated code to the OP, the $episodetitle is actually in a foreach statement, so there would be multiple pages which need to be created for each output.
Apr 28, 2021 at 12:25 comment added MMK yeah because you are passing one title $episodetitle. otherwise, it will create multiple pages under the same name.
Apr 28, 2021 at 12:23 comment added Daryl Roberts So this now just creates 1 page and HTML after the exit no longer displays, will try turning it into a function instead unless you have any other ideas
Apr 28, 2021 at 11:56 comment added MMK check now, i have added exit statement after insertion. wp_insert_post($seasonepisode); exit;
Apr 28, 2021 at 11:56 history edited MMK CC BY-SA 4.0
added 23 characters in body
Apr 28, 2021 at 11:25 comment added Daryl Roberts thanks but still creating an infinite loop of pages
Apr 28, 2021 at 11:09 comment added MMK i have updated the code, incorrect $parent->the_post(); it should have been "$children->the_post();"
Apr 28, 2021 at 11:07 history edited MMK CC BY-SA 4.0
added 4 characters in body
Apr 28, 2021 at 11:06 comment added MMK ok let me check
Apr 28, 2021 at 10:25 comment added Daryl Roberts Changing to $children->have_posts() and $child->the_post() just creates an infinite loop, any thoughts?
Apr 27, 2021 at 14:24 comment added MMK let me check...
Apr 27, 2021 at 14:23 comment added Daryl Roberts @MKK the alternative method throws no errors, but it is creating duplicate pages each time the page is refreshed
Apr 27, 2021 at 14:23 comment added MMK $parent->have_posts() sorry can you replace this with $children->have_posts()
Apr 27, 2021 at 14:13 comment added Daryl Roberts Thanks, I have tried the first updated code, but get the following errors: Notice: Undefined variable: parent Fatal error: Uncaught Error: Call to a member function have_posts() on null
Apr 27, 2021 at 14:03 comment added MMK yes, I have updated the first code to cater if there are no children. So basically we query children of the current page if there are some children then we start the loop and start matching titles. otherwise, if there are no children then simply a page is being added in else condition.
Apr 27, 2021 at 13:56 history edited MMK CC BY-SA 4.0
added 177 characters in body
Apr 27, 2021 at 13:09 comment added Daryl Roberts Thanks, I have updated the code as suggested in my original post, however pages aren't being created, in your first code, will this only create pages if there are already child pages under the current page?
Apr 27, 2021 at 10:47 history answered MMK CC BY-SA 4.0