How to get comment images stored as serialized comment meta

What you get is fine, it’s the image id, now you just need to loop them and output the structure that you want, for example. if (!empty($images = get_comment_meta( $comment->comment_ID , ‘reviews-images’, true ))) { foreach ($images as $image_id) { $image_src = wp_get_attachment_image_src($image_id, ‘full’); // Now you have the image src, $image_src, you can do … Read more

What is the best way to cache pages on WordPress

No, there isn’t. WordPress does not provide page caching mechanisms, and has no APIs for it. There is no generic way to say example.com/page is now stale and needs recreating. Nor is there any generic way to pre-generate every page short of visiting them all. Every plugin uses a different solution with different APIs and … Read more

How to conditionally add Custom Post Type to Front Page

I believe that if all your products have the custom meta field show_on_front_page with some containing ‘1’ and some containing ‘0’ or some such, AND your regular posts do not have that field, then something like below should work: //… $query->set(‘post_type’, array(‘post’, ‘product’)); //add this $meta_key = ‘show_on_front_page’; $query->set(‘meta_query’, array( ‘relation’ => ‘OR’, array( ‘key’ … Read more

Placing a widget with $wpdb query

Placing widgets via a MySQL or something MySQL abstracted via the global variable $wpdb that is an instance of the WPDB class is not trivial. That’s not because MySQL is something complicated or because $wpdb is useless at all but this has do something with the way the widget configuration is stored inside the mysql … Read more