Skip to main content
12 events
when toggle format what by license comment
Aug 23, 2012 at 4:24 vote accept Anthony Myers
Aug 23, 2012 at 4:09 comment added Anthony Myers Thank you sir! Yeah, actually after I posted the last question, I started looking at it, and thought it needed to go before the loop, but of course the "echo" was what I was missing. Now it's showing it. Awesome! I really appreciate your help! Now, so I'm thinking that if I can successfully wrap all my html with this loop, I can just drop in the <?php echo get_post_meta($post->ID, 'my_custom_field', true); ?> in the spots I need.
Aug 23, 2012 at 3:54 comment added mrwweb Two issues. 1) get_post_meta() doesn't echo anything, so if you want to display it, tack an echo in front of the last line of code. 2) It doesn't go in the loop. The loop is for querying posts which is what get_post() is doing. If you put it in the loop, you'll run that code snippet once for every post on your front page. Make sure to read the codex pages for each function so you understand what's going on.
Aug 23, 2012 at 3:42 comment added Anthony Myers Ok, so I'm not able to get it to do anything, and I'm sure I'm misunderstanding how this is supposed to work. This is what I'm trying: pastebin.com/8LMjmGsQ Is that anywhere near how I'm supposed to do it?
Aug 22, 2012 at 19:56 comment added Anthony Myers Fantastic! Thank you! I will begin playing with this and report back.
Aug 22, 2012 at 19:46 comment added mrwweb get_posts( 'numberposts=1' ); returns the most recent post's post object in an array. $my_most_recent_post[0]->ID; gets the ID of that post. So no. The whole point is that it's automatic.
Aug 22, 2012 at 19:41 comment added Anthony Myers Awesome, thank you for replying again! Now, that code you posted would have to be manually edited every time I post a new post though right? I would have to change the post ID number each day?
Aug 22, 2012 at 15:27 comment added mrwweb See the edit. I should add that "styling the loop" doesn't really have anything to do with the loop. The loop is purely PHP that outputs HTML. The HTML is what you style and you control what that HTML is.
Aug 22, 2012 at 15:26 history edited mrwweb CC BY-SA 3.0
added new code snippet
Aug 22, 2012 at 2:59 comment added Anthony Myers I'm trying it this way because just popping in <?php echo get_post_meta($post->ID, 'my_custom_field', true); ?> into my template is so much easier than trying to style the whole post that is ouput. I find it difficult to style the loop for some reason. It just has to automatically pull in the most recent data from the most recent published post. So the "published" post won't actually be visible, just portions of it that have been entered into the custom fields. I feel like I'm not explaining it well enough. I'm making it more confusing?
Aug 22, 2012 at 2:59 comment added Anthony Myers Ok, so I'm confused on how using WP_Query is different from how I normally pull in the loop in my projects. which I posted here: pastebin.com/ZHcjKbPr Can you help me out a bit more? How exactly do I get a custom secondary loop going? Can I get a secondary loop to work with the code I posted on pastebin? Or does it have to be completely separate?
Aug 21, 2012 at 5:51 history answered mrwweb CC BY-SA 3.0