How to add multiple images to a custom post type single post?

Thanks for the suggestions, guys. I did some more research, and found this – https://wordpress.org/plugins/attachments/ It’s a great plugin that lets you attach images to the post without inserting them in the post and the images can be easily sorted with ajax, it’s also quite modifiable and just what I needed, and works on custom … Read more

Adding items to page template dropdown on Page Edit Screen

I thought I would provide you with another approach. It is also a bit hackish, but it is general purpose and allows you to simply register the filename and label that you want to use, like so: if ( class_exists( ‘WPSE_196995_Page_Templates’ ) ) { WPSE_196995_Page_Templates::register_page_template( ‘My Page Template’, ‘my-page-template.php’ ); } You could add the … Read more

How to force Media manager to overwrite files of same name?

Here is something i cooked up which was taken mainly from the plugin Overwrite Uploads but without the extra stuff add_filter(‘wp_handle_upload_overrides’,’noneUniqueFilename’); function noneUniqueFilename($overrides){ $overrides[‘test_form’] = false; $overrides[‘unique_filename_callback’] = ‘nonUniqueFilenameCallback’; return $overrides; } function nonUniqueFilenameCallback($directory, $name, $extension){ $filename = $name . strtolower($extension); //remove old attachment removeOldAttach($filename); return $filename; } function removeOldAttach($filename){ $arguments = array( ‘numberposts’ => … Read more

How to set a fall back template for a custom post type in a plugin?

To provide a default template that can be overwritten by a theme hook into template_include like the linked questions suggest. You get the template WordPress wants to use as a parameter. If that is not the file you want – replace it with your plugin’s file: add_filter( ‘template_include’, ‘wpse_57232_render_cpt’, 100 ); /** * Provide fall … Read more

Why doesn’t /2013/01/ properly return January’s archives in archive.php?

Don’t use query_posts in the template for simple modifications of the main query. Use the pre_get_posts action instead to modify the query before it runs: function wpa_date_posts_per_page( $query ) { if ( !is_admin() && $query->is_date() && $query->is_main_query() ) { $query->set( ‘posts_per_page’, 5 ); } } add_action( ‘pre_get_posts’, ‘wpa_date_posts_per_page’ );