Show preset taxonomy description

Assumptions: institute is the taxonomy course is the term only one course is assigned per post you want to display the course description? If so, the simplest way would be to use get_the_terms(). If your taxonomy is institute, you can do something like the following: <?php // globalize $post global $post; // Get the course … Read more

Showing image description along with embedded links below post images

When you look at the last line img_caption_shortcode(), then you can see wp_kses() stripping non allowed HTML tags there. The wp_kses_hook() function does only wrap a filter: return apply_filters( ‘pre_kses’, $string, $allowed_html, $allowed_protocols ); which allows to hook in and alter the output before wp_kses_split() finally removes the HTML tag by using preg_replace_callback with _wp_kses_split_callback() … Read more

Return post tags with description

This is how you can loop with custom taxonomy. function returnpost_tags(){ // get tags by post ID $post_ID = get_the_ID(); // here, you can add any custom tag $terms = get_the_terms( $post_ID , ‘post_tag’ ); echo ‘<ul>’; foreach ( $terms as $term ) { // The $term is an object, so we don’t need to … Read more

Add description to custom text widget and display the 5 recent post titles

You are not passing your description correctly. Really, you aren’t passing it at all. public function __construct() { parent::WP_Widget(false, $name=”Kevins Textbox”); array(‘description’ => __(‘A text widget created by Kevin Ullyott for practice in creating widgets’) ); } That ‘description’ line is creating an array but you aren’t doing anything with it. It is just floating … Read more

Get meta data from image

Image data is stored as if it were a post, or a CPT, so you can treat it like one. $album_id = get_the_id(); $img = new WP_Query(array(‘p’=>$album_id,’post_type’=>’attachment’)); var_dump($img->posts[0]->post_content); Or, a little more complicated,… $album_id = get_the_id(); $img = new WP_Query(array(‘p’=>$album_id,’post_type’=>’attachment’)); if (!empty($img->posts[0])) { var_dump($img->posts[0]->post_content); } get_the_ID will return the ID of the current post so … Read more

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