Skip to main content
14 events
when toggle format what by license comment
Feb 25, 2016 at 4:25 history edited Sumit CC BY-SA 3.0
added 2 characters in body
Feb 24, 2016 at 18:41 comment added Alexander Graham @Sumit solved! Changed order to orderby. :) Thank you so much for the help!
Feb 24, 2016 at 18:41 vote accept Alexander Graham
Feb 24, 2016 at 20:16
Feb 24, 2016 at 18:30 comment added Alexander Graham @Sumit Updated core code. Ok, I got it, it's working, but it's not pulling random post. It's only pulling latest.
Feb 24, 2016 at 18:08 comment added Sumit @AlexanderGraham Updated my answer please check! $ad_code variable should be used in your function prefix_insert_after_paragraph( $ad_code, $show_after, $content ); and for pulling a post only if have meta field already filled, you need to add meta query as well!
Feb 24, 2016 at 18:06 history edited Sumit CC BY-SA 3.0
added 88 characters in body
Feb 24, 2016 at 17:50 comment added Alexander Graham Nope, still missing something ... I wish I knew PHP more. Let me try a few things and I'll let you know. I have a feeling your code is getting me close to let me try a few things. The post-type should pull an ad that has those fields already filled out. Just need to get it posted into the content ... hmm.
Feb 24, 2016 at 17:05 comment added Sumit This is because of line number 28, $random_ad should be Ad HTML that is variable $ad_code
Feb 24, 2016 at 16:42 comment added Alexander Graham Ok, this is good, as I now understand a bulk aspect of what I need to do. However, I'm running into an error, Catchable fatal error: Object of class WP_Post could not be converted to string. Here's my pastebin.
Feb 24, 2016 at 16:35 comment added Sumit Code updated...
Feb 24, 2016 at 16:33 comment added Sumit Yes of course but good for getting single post and without setting up post data!
Feb 24, 2016 at 16:30 history edited Sumit CC BY-SA 3.0
added 36 characters in body
Feb 24, 2016 at 16:29 comment added Tom J Nowell Of note, get_posts uses WP_Query internally, also this code doesn't check if $random_ad is empty correctly, and should use if ( !empty( $random_ad ) ) { instead
Feb 24, 2016 at 16:24 history answered Sumit CC BY-SA 3.0