Image does not appear when WP cannot find page
-
Hallo Micah
I have a problem with a random image not appearing when I use the random image shortcode and when no post(s) or page(s) can be found and shown. But when the url can show a post or page, then the random image appears. I see the problem in my own custom theme, but also in all WordPress 4.7.3 default themes Twenty Fifteen, Twenty Sixteen and Twenty Seventeen.
The situation is not a real problem for normal page navigation, because a page is always shown. (But I see the problem if I just give a false Url). The situation is more a problem when I am searching (with the default WP search function) and there is no page for the given search terms.
Test setup
So what I have done is :
WordPress 4.7.3
Plugins installed
Plugin : Mpress Image Refresh, version 2.1
Plugin Simple Testimonials from Pixelovely, version 1.0.0
No other plugins installedWherever I insert your shortcode I also insert immediately after, a random text shortcode from plugin Simple Testimonial from Pixelovely :
[mpress_image_refresh attachment=”71, 72, 73,74″]
[testimonial number=2]With the 3 WP default themes I insert both shortcodes in a text widget in all available widget areas for each theme.
And with my own custom theme, I insert both shortcodes directly in a left and right sidebar with do_shortcode() – the page/post content fetch is just the normal WP default loop – The template snippet for the left, content, and right areas is :
<div id="sidebar-left"> <?php echo do_shortcode('[mpress_image_refresh attachment="71, 72, 73,74"]'); ?> <?php echo do_shortcode('[testimonial number=2]'); ?> </div> <div id="page"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?><h2><?php the_title(); ?></h2><?php the_content(); endwhile; else: ?> <p><?php _e('Sorry, no posts/pages matched your criteria.'); ?></p> <?php endif; ?> </div> <div id="sidebar-right"> <?php echo do_shortcode('[mpress_image_refresh attachment="71, 72, 73,74"]'); ?> <?php echo do_shortcode('[testimonial number=2]'); ?> </div>
My normal case : What I am wanting when things are working, is to use my own custom template, and insert your random image shortcode via a text widget in the left sidebar only .. so then the attachment ids can be changed from the Backend
Test cases
I then have 2 test cases in the Frontend :
Case A : The browser shows a valid page (the browser Url corresponds to an existing page or the search fn finds pages which have term that is in the value of the search Url param s ).
Case B : The browser does not show a valid page (the browser Url does not correspond to an existing page, or the search fn has not found any pages)Result
Case A
The random texts of shortcode [testimonial] always show in all themes
The random image of the shortcode [mpress_image_refresh] always show in all themesCase B
The random texts of shortcode [testimonial] always show in all themesFor the WP default themes I get for each Widget Area :
a. Twentyfifteen:
i. Widget Area : Goodb. Twentysixteen
i. Sidebar : Good
ii. Content Bottom 1 : Bad
iii. Content Bottom 2 : Badc. Twentyseventeen
i. Sidebar : ?
ii. Footer 1 : Bad
iii. Footer 2 : BadWhere Good = The random image shows, Bad = The random image does not show
And with my custom theme I do not see any random image at all left or right.
Note, if Mpress Image Refresh is the ONLY plugin installed, I get the SAME problem.
So in conclusion , … do you know what the problem may be ?
Cheers aldebaran57
- The topic ‘Image does not appear when WP cannot find page’ is closed to new replies.