Using file_exists to check file in Uploads

You can’t use a file url in file_exists() like this: file_exists( “http://example.com/wp-content/uploads/Example_Name_2_SM.jpg” ); You should rather use an absolute file path, for example: file_exists( “/absolute/path/to/wp-content/uploads/Example_Name_2_SM.jpg” ); Then you should try $meta = get_post_meta( $post->ID, ‘_meta_example_name’, true ); $file = $upload_basedir . “https://wordpress.stackexchange.com/” . $meta . ‘_7_SM.jpg’; if ( file_exists( $file ) ) { //… } … Read more

Create Image Uploader for Widget

Let’s face it in detail: The registered sidebar (with the ID left-sidebar) has two arguments to wrap the whole widget (before_widget and after_widget) which you can output via echo $before_widget and echo $after_widget in your widget (see my version below): <?php // Register sidebar if (function_exists(‘register_sidebar’)) { register_sidebar( array( ‘name’ => ‘Left Sidebar’, ‘id’ => … Read more

Display posts by month

As said in a comment, you can do this in one query. The principle here is to only display the date heading if the post date’s month of the previous post does not match that of the previous post FEW NOTES Before I start, a few notes: Never use query_posts, except if you really need … Read more

WordPress the_content() return only one image from a specific category

You are trying to get the ID via $post->ID, but that will only return the post ID of the first post. You can use global $post; before the args array, or much simpler replace $post->ID by the function get_the_ID(). $args = array(‘post_type’ => ‘attachment’, ‘numberposts’ => 34, ‘post_status’ => null, ‘post_parent’ => get_the_ID());