I'm fairly new to wordpress development ( coming from drupal ).

Recently I was tasked with creating a system to export posts into an xml format, and by and large this is fine, though one thing to note is that the action im currently hooking into is add_action('wp_footer','my_function'); though I have also set the system up to run within a wp-cron job ( this is disabled, but it also fails here ).

Inside 'my_function' I build an array which I later convert into xml.

as part of this I need to get the url to use so I use

$url = get_permalink($id);

commenting out this line and doing

$url='some text';

has no issues at all, so I KNOW that it's the get_permalink thats causing the whitescreen.

I'm doing this a LOT ( about a thousand times) am I just killing it because get_permalink is a memory hog, or is there something else? Is there a lightweight ( 'hacky') way to get the url?

foreach ($results as $key => $value) {
  $url= get_permalink($value->ID);
  echo "processed record :".$key."<br/>\r\n";
  • please show your code – inarilo Sep 8 '17 at 16:08
  • @inarilo yeah added, see how much it helps... had you actually read my question properly you would know that commenting out the line in question and using a simple placeholder shows there are no issues with the rest of the code. when get_permalink() is used repeatedly it causes issues. – Jesterscup Sep 8 '17 at 16:36
  • i did read your question properly, it doesn't matter whether the rest of the loop works or not, you need to show where $id is coming from first of all - now from the added code i see it's coming from a result set, but you have not shown the code that gets the result set, which is one possible source of the error, furthermore, it's not possible to find bugs without seeing all relevant code, people here are taking time out to help each other, there's no excuse for acting snippy because someone asked for the obvious. and finally, you are supposed to show all relevant code when asking a question. – inarilo Sep 8 '17 at 18:22
  • Enable debugging so you can see the error message being generated. – Milo Sep 8 '17 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.