Loading all files within a directory

Loading files from a directory – the historical way The glob() function has three possible return values: Array( filenames ) => success Array() empty => nothing found FALSE => Error So the correct check would be $files = glob( sprintf( ‘%s/postypes/*.php’, get_stylesheet_directory() ) ); if ( empty( $files ) { _e( ‘No PHP files found’, … Read more

Get category name from custom loop and echo it once

Here is an idea. Note, this will only work if all posts are in the desired category and if all posts have only category The posts are returned in an array which you can access through $currentissue->posts With this in mind, you can get the first post ID as follows $currentissue->posts[0]->ID Now, you can add … Read more

Validate Uploaded Image using WordPress’ Built-in Functions?

All of the code in your question can be replaced with: require_once( ABSPATH . ‘wp-admin/includes/image.php’ ); require_once( ABSPATH . ‘wp-admin/includes/file.php’ ); require_once( ABSPATH . ‘wp-admin/includes/media.php’ ); if ( $_FILES ) { foreach ($_FILES as $file => $array) { $image_post_id = media_handler_upload( $file ); if ( is_wp_error( $image_post_id ) ) { $error .= $image_post_id->get_error_message(); } else … Read more

How to get to a specific position in wp_query?

I think instead of using PHP rand you’re better off limiting ( if you need to ) using posts_per_page and then getting a random set using orderby => ‘rand’. Full List of Ordering Parameters So if I were to edit your query it would look like this: $args = array( ‘post_type’ => ‘attachment’, ‘meta_key’ => … Read more

Deregister and Dequeue Stylesheets From a Plugin and Enqueue a Child’s Stylesheet/s

As kaiser noted, you probably need a higher priority. add_action( ‘wp_enqueue_scripts’, ‘load_alta_styles’, 20 ); But if not, you can use wp_style_is to check and see after you do things if they are as expected. e.g. you might try: if ( wp_style_is( ‘wp_listings_single’, ‘enqueued’ ) ) { wp_dequeue_style( ‘wp_listings_single’ ); echo ‘<p>Seems to have been dequeued</p>’; … Read more