PHP code to call image Caption, Alternative Text, and Decription?

WordPress stores image (attachment) data as follows: Description: post_content field Caption: post_excerpt field Alt: _wp_attachment_image_alt meta value And in code, that translates to: // Description echo $post->post_content; // Raw the_content(); // Caption (description as fallback) the_excerpt(); // Caption (explicitly) echo $post->post_excerpt; // Raw if ( has_excerpt() ) { the_excerpt(); } // Alt echo get_post_meta( $post->ID, … Read more

WordPress with php 5.5 and zend opcache

Opcache is transparent for WordPress (as it is to any PHP application). However if you had been using APC for object cache (key/value store) via plugin — that function is not available in new bundled Zend cache, it only does opcode caching. You would need to replace object cache with something different (APCu/Memcache/Redis/etc).

have_posts() execution failure

Your problem is the weird code at the top of the page. To understand what’s happening let me state a standard loop in pseudocode: if we still have posts to process while we still have posts to process mark this post as processed and move to the next one do things with it ( like … Read more

How can I use wp_insert_comment to write a comment when a post is edited?

Try using the following code in the functions.php file of your child theme theme. function add_comment_on_post_update( $post_id, $post_after, $post_before ) { // If this is just a revision, don’t send the email. if ( wp_is_post_revision( $post_id ) ) return; if (defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE) return; if (isset($post_before->post_status) && ‘auto-draft’ == $post_before->post_status) { return; } if (‘post’ … Read more

Run a filter when a walker runs

If all of it is your own code then it would be reasonable to just implement that as part of walker. If you need to add a filter while third party walker runs you could probably: Add it at wp_nav_menu_args hook, checking if walker is set to that: add_filter( ‘wp_nav_menu_args’, function( $args ) { if … Read more

How to get media objects

Have you tried to use get_children() function? Edit: All media attached to any post is treated as children of it. The function wp_get_attachment_image() will only return images. With the function get_children() you’ll be able to get all the media, images or anything else. In the above link, you can find some examples.