Drew Gourley
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Empty Archives Returning 404Further Investigation reveals this to be a more complete solution:
function dg_override_404() { global $wp_query; $args = array( 'public' => true, '_builtin' => false ); $post_types = get_post_types($args); if ( in_array($wp_query->query_vars[post_type], $post_types) && $wp_query->is_404 == true ) { $wp_query->is_404 = false; $wp_query->is_archive = true; $wp_query->is_post_type_archive = true; } } add_action('pre_get_posts', 'dg_override_404'); function dg_override_template() { global $wp_query; $args = array( 'public' => true, '_builtin' => false ); $post_types = get_post_types($args); if ( in_array($wp_query->query_vars[post_type], $post_types) && $wp_query->is_404 == true ) { include(TEMPLATEPATH.'/archive.php'); exit; } } add_action('template_redirect', 'dg_override_template');
I still need to find a way to change the headers to 200 instead of 404 and to circumvent the ‘Page not found’ from showing up in the title of the page.
Forum: Fixing WordPress
In reply to: Empty Archives Returning 404Hey guys, ran into this myself with some hard work created this solution:
You can toss this into functions.php in your template and it will give you the desired effect.
function dg_override_404() { global $wp_query; $args = array( 'public' => true, '_builtin' => false ); $post_types = get_post_types($args); if ( in_array($wp_query->query_vars[post_type], $post_types) && $wp_query->is_404 == true ) { $wp_query->is_404 = false; } } add_action('pre_get_posts', 'dg_override_404'); function dg_override_template() { global $wp_query; $args = array( 'public' => true, '_builtin' => false ); $post_types = get_post_types($args); if ( in_array($wp_query->query_vars[post_type], $post_types) && $wp_query->is_404 == true ) { require TEMPLATEPATH.'/archive.php'; exit; } } add_action('wp', 'dg_override_template');
Basically what this does is only firing when your on an non-built-in post type that is returning a 404 error, which is only the case on empty post type archive pages. It switches the is_404 argument to true and forces it to use the archive template. I’ll investigate this more tomorrow, because it probably requires some refinement.
Forum: Plugins
In reply to: [Plugin: Multiple Post Thumbnails] Image not displayingHa, nice.
Really odd is that it works for me both ways…
Forum: Plugins
In reply to: [Plugin: Multiple Post Thumbnails] Image not displayingSorry to hear that this didn’t work, but there is one difference between yours and mine. I changed the way the condition was formatted. This is a long shot, because everything you’ve done SHOULD make it work, but it hasn’t… Here is the exact code from my page.php:
<?php if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('page', 'secondary-image')) { ?> <div id="secondaryImage"> <?php MultiPostThumbnails::the_post_thumbnail('page', 'secondary-image'); ?> </div> <?php } ?>
And the div isn’t necessary, its for CSS so:
<?php if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('page', 'secondary-image')) { MultiPostThumbnails::the_post_thumbnail('page', 'secondary-image'); } ?>
Forum: Plugins
In reply to: [Plugin: Multiple Post Thumbnails] Image not displayingmake sure that the post type matches up with the post type you declared when you register the post thumbnails.
The author shows
$thumb = new MultiPostThumbnails(array( 'label' => 'Secondary Image', 'id' => 'secondary-image', 'post_type' => 'page' ) );
but then incorrectly tells you to put this in the template:
<?php if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('post', 'secondary-image')) : MultiPostThumbnails::the_post_thumbnail('post', 'secondary-image'); endif; ?>
if you registered it as post-type => page, then you’d have to use:
<?php if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('page', 'secondary-image')) : MultiPostThumbnails::the_post_thumbnail('page', 'secondary-image'); endif; ?>
This got it all working for me.
Don’t forget, this is really versatile! You could literally register ten or more post-thumbnails by giving them unique identifiers when registering them. Exciting stuff!