PHP Mess up
-
Hey guys.
So I'm still fairly new to the website world, my friend gave me some code that was working perfectly, I thought I only cut and pasted a piece of code, found it didnt work, and put it back. Obviously I may have done something else though?
// LOOP if ( $ocquery->have_posts() ) : while ( $ocquery->have_posts() ) : $ocquery->the_post(); $content = preg_replace('/(<)([img])(\w+)([^>]*>)/', '', $content); $content = get_the_title(); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); $url = get_permalink(); $img = get_the_post_thumbnail($the_post->ID, 'thumbnail'); printf ('<li><div class="slide"> %s <a href="%s"><input class="bluebutton blue" type="button" value="Click here to see this post!" />%s</a> </div></li>', $content, $url, $img,; ) endwhile; endif; echo '</ul></div></div></div></div>'; wp_reset_query(); // reset the query
Would anyone be able to tell me where my "whoopsie" is, what I did was remove the $img, and try to put it infront of the $url, then put it back (obviously wrong though)
Thanks much appreciated.
-
Disclaimer: Don't know squat about PHP
Careful when copy/paste code, it can copy the formatting and introduce errors. If using windows I think you can eliminate this by copying with........ I'll google it and edit in a sec.switch from using CTRL+V (Paste) to CTRL+SHIFT+V (Paste Plain Text).
http://www.howtogeek.com/186723/ask-htg-how-can-i-paste-text-without-the-formatting/
-
Using This Website I feel it should be a 3 second fix but I cant seem to get it?
-
Bah got it
printf ('<li><div class="slide"> %s <a href="%s"><input class="bluebutton blue" type="button" value="Click here to see this post!" />%s</a> </div></li>', $content, $url, $img ); endwhile;
-
Put five ~ on a line above and below your code to properly format it, otherwise it's basically unreadable on this forum since Markdown will try to parse PHP symbols into formattable text.
-
Ah that looks much prettier, thanks for the tidbit of advice