• Resolved aldebaran57

    (@aldebaran57)


    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 installed

    Wherever 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 themes

    Case B
    The random texts of shortcode [testimonial] always show in all themes

    For the WP default themes I get for each Widget Area :
    a. Twentyfifteen:
    i. Widget Area : Good

    b. Twentysixteen
    i. Sidebar : Good
    ii. Content Bottom 1 : Bad
    iii. Content Bottom 2 : Bad

    c. Twentyseventeen
    i. Sidebar : ?
    ii. Footer 1 : Bad
    iii. Footer 2 : Bad

    Where 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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter aldebaran57

    (@aldebaran57)

    Hallo Micah

    I may have made a mistake with what I said for the default themes 2015-7. Upon doing a search, the search results are displayed with template file search.php, and for the default themes I am not sure what actual widget areas the search.php file has .. So upon a search your random image may not be shown in the footer by design because there is no widget area there !

    BUT I definitely have the problem I describe for my custom theme. For this I have 2 template files index.php and search.php. They are identical, except that the loop to fetch the page content has the_content() for index.php and the_exerpt() for search.php. The body code for index.php is above in previous message

    Any help with this would be appreciated

    aldebara57

    @aldebaran57

    Thanks for catching this and documenting the issue so well! I’ve pinpointed the issue and released version 2.1.1 to fix it. You should be able to update to the latest version now.

    Thread Starter aldebaran57

    (@aldebaran57)

    Hello Micah

    Thanks for the quick response ! So you found the problem. I tested the updated 2.2.1 version, and now works great, no more disappearing images !

    .. I had no idea that the two aspects, media library images and posts, could be related, but it seems they are. I’ve got some WP learning to do

    Thanks again
    @aldebaran57

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Image does not appear when WP cannot find page’ is closed to new replies.