How do I add php to all links automatically?

Inserting PHP is not really the way you want to do this. You would then need additional code to execute the PHP in the post body. It could be complicated. Replace the links using a filter on the_content. Something like this: function replace_urls_wpse_91463($matches) { $ret=”<a”; if (isset($matches[1])) { $ret .= $matches[1]; } if (isset($matches[2])) { … Read more

How to add different CSS for galleries

What I would do is open it up in chrome, inspect element, and check to see if the featured image has a different ID or CLASS to the other images in the gallery. Then I would add an additional line to my CSS that targets those ID/CLASS. In the event that a ID/CLASS aren’t unique … Read more

Get the url of attachments from the post?

I think you’re going about it the wrong way. You can use get_posts to get the attachments of the current post: $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘post_status’ =>’any’, ‘post_parent’ => $post->ID ); $attachments = get_posts($args); if ($attachments) { foreach ( $attachments as $attachment ) { echo apply_filters( ‘the_title’ , $attachment->post_title ); … Read more

How to make plugin work in each template in wordpress

You would have to put your code in your question into a function. Maybe something like function wpse_91897_get_image() { }. Then try the code below. I haven’t tested this but it should work. function wpse_91897_display($content) { global $single; $output = wpse_91897_get_image(); if (is_single()) { return $content . $output; } else { return $content; } } … Read more

Adding Relevant Post Images

This plugin sounds like what you’re looking for. It uses post tags to find all relevant posts. Upload it to your plugins directory and activate it. Then just decide where you want it on your site and add post tags to get content to relate to each other. http://wordpress.org/extend/plugins/igit-related-posts-with-thumb-images-after-posts/ Note. I am not the developer … Read more

Custom Function for SEO by Yoast plugin

What you need is get_post_meta instead of get_post_type This: if ( get_post_type( $post->ID ) == ‘design’ ) { Should be: $meta = get_post_meta($post->ID,’your-meta-key’,true); if (!empty($meta)) { Put altogether function design_canonical_wpse_93717() { global $post; $meta = get_post_meta($post->ID,’your-meta-key’,true); if (!empty($meta)) { return $meta; // assuming this is an absolute URL } } add_filter( ‘wpseo_canonical’, ‘design_canonical_wpse_93717’ ); The … Read more

Problem with executing a function on saving a post

The action save_post is also called during AJAX auto-save requests. But your value is not sent then, so you save an empty value for something that isn’t set. Start your save function with: if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return; See basic examples with more checks here and here.