Dynamic Title for custom post types

I use something like this in my header.php: <title> <?php if(is_front_page()) echo “Front Page Title”; else if(is_404()) echo “Page Not Found”; else the_title(); echo ‘ | ‘.get_bloginfo(‘name’); ?> </title> Check out Conditional Tags for more information. As a Function() : functions.php function setTitle(){ global $post; $title = get_the_title(); $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), … Read more

Get Value of Custom Field

As the $posts are the posts of post_type abschreibungstabelle, you can get the custom field values by using get_post_custom_values if( ! $posts ) return; $out=”<select id=”afa_select”><option>Anlagegut auswählen</option>”; foreach( $posts as $p ) { $custom_field_value = get_post_custom_values( ‘nutzungsdauer’, $p->ID ); // Now you can use the value the way you want $out .= ‘<option value=”‘ . … Read more

Retrieve array of attachment IDs attached to a given Post ID

found a solution: thought it might be worth sharing… //// We use $gallery_media as an array containing all attachment IDs that have been approved by the admin before $args = array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => -1, ‘orderby’ => ‘post_date’, ‘order’ => ‘ASC’, ‘post_status’ =>’any’, ‘post_parent’ => $post->ID, // This queries a custom field I … Read more

Dynamically Generating User Meta Field

After some help with a PHP developer, it seems the main code above was close but certain changes were made. Here is the code for those interested. In this code, the custom post type is: Course. Change accordingly if needed for your own use. function save_educadme_courses_for_user( $user_id ) { if ( !current_user_can( ‘edit_user’, $user_id ) … Read more

Dynamically adding Captions to images

The media uploader wraps the image and caption in the shortcode. There is a filter called img_caption_shortcode that can do what you want. The caption itself is passed as part of an array to the shortcode handler, as is the image id. add_filter( ‘img_caption_shortcode’, ‘wwm_img_caption_filter’, 10, 3 ); function wwm_img_caption_filter( $empty, $attr, $content ) { … Read more