• Resolved ljkerley

    (@ljkerley)


    Hi there:-
    The navigation and loading of text of previous posts isn’t working properly. The blog correctly shows the most recent post. However, on clicking the permalink to a previous post, the browser window shows the correct URL but fails to load the corresponding text. It continues to show the text from the most recent post. (So there is a mismatch between the URL and the rendered text.)
    Originally I had the blog set to show only 1 post at a time (under Settings -> Reading). My first thought was to change this, in case it was causing the problem. I changed it to 5 posts. Strangely this had no impact. At minimum I would have expected to see my two posts shown one underneath the other.
    This made me think that the problem might be in my loop somewhere(?).
    However, I didn’t see a problem in the code:
    <div id=”postContent”>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <h1><?php the_title(); ?></h1>
    <p class=”metaData”>Posted by <span class=”postAuthor”>Linda Kerley</span> | <?php the_time(‘F jS, Y’) ?></p>

    <p><?php the_content(__(‘(more…)’)); ?></p>

    <h3 class=”comments”>Reader feedback:  <?php comments_popup_link(‘0 Comments. Be the first. »’, ‘1 Comment »’, ‘% Comments »’); ?></h3>

    <!–Here we show comments per post –>
    <?php comments_template(); // Get wp-comments.php template ?>

    <?php endwhile; else: ?>
    <p><?php _e(‘Sorry, no posts matched your criteria.’); ?></p>

    <?php endif; ?>

    Is it perhaps a setting somewhere?
    Default blog URL: https://www.userelement.com/blog/
    Permalink to previous blog post: https://www.userelement.com/blog/websites/understanding-website-pricing-2/

Viewing 9 replies - 1 through 9 (of 9 total)
  • since none of your links I checked load correctly, I would completely delete the wordpress .htaccess – then reset the custom permalinks
    dashboard – Settings – permalinks

    Thread Starter ljkerley

    (@ljkerley)

    Hi Samboll,
    Could you elaborate on what you mean by resetting the custom permalinks? I deleted the blog .htaccess file as you suggested (no impact so far), but am unsure about the resetting. Do you mean just save the custom setting again? I am hesitating because I am worried that any inbound links to the first post will be damaged as a result.
    Also, your mention of the .htaccess file caught my attention because I have an .htaccess file at the parent level of the whole site. This made me wonder if there is some kind of conflict (of course deleting the WP .htaccess would presumably correct that.) It’s just that I didn’t create the WP .htaccess. Is it part of the standard install?

    the .htaccess is created when you 1st set/save permalinks

    Do you mean just save the custom setting again? I am hesitating because I am worried that any inbound links to the first post will be damaged as a result.

    yes just save them again – no links will be damaged/lost

    Thread Starter ljkerley

    (@ljkerley)

    Ok, so I tried this but unfortunately it didn’t work. The same behaviour – correct url but wrong text – is still happening.
    At one point I wondered if the database was messed up. So I checked to see if the post text was still in the admin console (Posts -> Edit -> Edit) and it is. However, I noticed when I preview the post, the preview shows the most recent post. (I offer this info in case it provides a clue.) … it is like WP has lost the association of the link to the text somehow.

    Thread Starter ljkerley

    (@ljkerley)

    … but even then, if the association between URL and text was lost, then when clicking on the URL I would expect no text to appear. Instead it keeps loading the text from the most recent post. I am puzzled …

    Thread Starter ljkerley

    (@ljkerley)

    Could the structure of the website have something to do with the rewrite rule not executing correctly?
    I added the WP blog to an existing website. The entire blog is in a subdirectory of the site, e.g.
    https://www.userelement.com
    – images
    – scripts
    – blog
    … various wordpress directories and files

    I have an .htaccess at the root of the site. The code is here:
    RewriteEngine on
    rewritecond %{http_host} ^userelement.com [nc]
    rewriterule ^(.*)$ https://www.userelement.com/$1 [r=301,nc]

    Then I guess WP generates its own .htaccess when permalinks are in use. The WP .htaccess file code is here:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    </IfModule>

    # END WordPress

    Are these somehow in conflict (although again if the files weren’t being found I would expect a blank page or 404…)

    none of that should matter – it’s fairly standard

    you must have a plugin messing with you
    deactivate them all – the activate one by one, testing in between
    if that’s not it, switch to default theme to rule out theme problems

    Thread Starter ljkerley

    (@ljkerley)

    Hi Samboll,
    I have no plug-ins installed.
    I installed two different themes (default and another that I had borrowed some code from), and the problem disappeared.
    So I guess the good news is that the problem is not caused by my permalink setup or my .htaccess files.
    Next challenge: I borrowed some code from both of the above themes in my theme, so it is not immediately obvious to me what aspect of my theme might be causing the problem… Does anything jump out at you? (Likely suspects?)

    Thread Starter ljkerley

    (@ljkerley)

    Ok, so I found my own solution to this problem.
    My blog has a 3-column format, e.g. #leftSideBar, #postContent, (right)#sidebar. I originally had the navigational functions, e.g. posts by category, by archive date, etc. in the PHP file of leftSideBar, which was a custom template. As soon as I swappped the content of the sidebars so that the navigational functions were in the standard PHP template ‘sidebar.php’ everything worked.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Permalink correct but page fails to load corresponding text’ is closed to new replies.