last day (14 days later) » 

12:51 AM
0
A: How do you get all the urls of images attached to a post?

Jason MurrayYou need to loop through the attachments within your post loop, replace the section of code you posted with this (put this together from some other code I found related to a similar problem, but couldn't test it): </BasicDetails> <?php $args = array( 'post_parent' => $post->ID, ...

 
Will test it now, is the last tag open? and } necessary?
 
@Marco assuming some kind of php code immediately follows this piece of code the last tag should be open yes, if you are echoing out more tags you can just stick a ?> on the end. So it will be either as posted <?php } or <?php } ?>
 
Gotcha, though I added the above if( statement in function.php and it crashed my site. I should of mentioned that I was using a commercial theme which is heavily customized.
 
@Marco can you update the question with the whole section of functions.php relating to this and any front end code.
 
I updated my question with the XML file that I'm using.
 
12:51 AM
@Marco I have updated the solution and supplied a bit of context to the beginning and end of the code block, let me know how you get on. If it goes to white screen again can you turn on wp_debug in wp-config.php and check what error it is giving?
 
will try it as soon as my server comes back up (Unrelated but don't use bluehost)
Wonderful!! If your were in NYC I'd buy you a beer. I do have one more issue, the post_per_page for some strange reason is capping at 45. When I put -1 I get a parse error. Any ideas?
 
@Marco I wish! Well you could try adding nopaging => true, to your posts query arguments near the top.
 
haha, well if you ever are let me know! nopaging didn't seem to work. Maybe I should start a new question.
 
@Marco your options for the post query are a little messy, I'll post some revised ones in a moment but you dont need all those option => '', entries
This should work as a replacement for the code near the top of your page: pastebin.com/a9ALtdJ1
 
I know, it was dirty, i was going to start cutting it down once I figured out how to get all posts. Thanks, I updated it.
@JasonMurray I know, it was dirty, i was going to start cutting it down once I figured out how to get all posts. Thanks, I updated it.
 
1:09 AM
@Marco did it work?
 
Nope
@Jason I added nopaging it didn't work.
@JasonMurray "XML Parsing Error: undefined entity
Line Number 8182, Column 4:<p>&nbsp;</p>
---^"
 
Oh this must be because we are not sanitizing the captions for the images.
So the code is working it just happens to be that one of our image captions has invalid xml characters.
 
@Jason I took out the captions already, could it be description and i need <![CDATA[
 
can you link me the page that's throwing the error? remember chat is public.
 
@JasonMurray why would it work up to 45 then throw the error?
 
1:19 AM
Because the first 45 posts just happen to have all xml compliant code.
Line 8182 is part of the description for Willow St 1 Bedroom
yes you're right, you need to implement cdata tags!
@Marco
 
@Jason Yeah, I thought I had it was giving me an error before so I stripped it. Let me give it another try
 
@Jason Yup, it works, the ampersand in the address of those listings were it. I can't thank you enough!!
 
1:34 AM
@Marco no problem, you should probably run the strings through htmlentities(); as you echo them, this will replace the invalid chars with entity reference like &amp;
 
@Jason thanks for the reference, totally will here on out. you have any contact info in the event to reach out?
 
1:57 AM
@Jason I'm on twitter.com/jsn256 throw me a follow!
@Marco ... Tagged myself?! It's late here haha
 
@Jason haha done. And thanks again!
 

last day (14 days later) »