• Resolved will_pigeon

    (@will_pigeon)


    Hi,

    I’ve tried searching and can’t find an answer.

    I have pages of posts being created with no wp_title, I don’t understand why they are being created and they lead to a 404 error. They list the posts on my site in date order, 5 per page.

    The format of the url is:
    http://www.myblog.com/page/1/

    Specifically my urls are:
    http://www.pinkpigeon.net/page/1/
    to
    http://www.pinkpigeon.net/page/4/ there is a button on this page linking to page 5 but it returns a 404 error.

    I don’t want these pages, how do I stop them from being created?

    In terms of google indexing the pages, do you advise creating a redirect for these pages or blocking them with robots.txt?

    thank you

    Will

Viewing 15 replies - 1 through 15 (of 17 total)
  • I don’t want these pages, how do I stop them from being created?

    You can remove the links to these pages by editing the relevant theme template file (index.php?) and removing <?php next_posts_link();?> and <?php previous_posts_link();?>. However, this does mean that your site visitors will not be able to access older posts from your Home page as they are pushed off the first page.

    There’s no need to carry out any redirects for Google. Blocking them via robots.txt may also damage your SEO.

    Thread Starter will_pigeon

    (@will_pigeon)

    Hi Esmi,

    Thank you for the swift reply. Your suggestions works however it does, as you say, prevent visitors from accessing older posts.

    A bit more detail about my site; the Home page is a page, my posts are linked to via Blog and Portfolio categories. Your suggestion worked fine (my blog template “older entries” button still worked) but where I have tags with more than 5 entries, if I click on the tag it only lists the first 5 posts – there isn’t an “older entries” button.

    The problem pages I mentioned, it is as if they are a list of tag pages where no tag has been selected. There is no h1 where normally there would be “Posts Tagged ‘Tag Name'”.

    It is not possible to link to these pages from within the site. I only noticed them because google has indexed them, so they must be created somehow?

    Thank you for the advice re-google.

    One further observation, the theme came with WP-PAgeNavi installed, however there is no code <?php wp_pagenavi(); ?> in footer.php.

    If this helps, here is my index.php code

    http://wordpress.pastebin.com/SBzQ9S3D

    These aren’t “Pages” as such. They’re dynamically-created post lists – created on demand when someone selects the Older/Previous Posts link. The fact that the theme is bundled with WP-Pagenavi may be the cause of the 404 problem. WP-Pagenavi may not be implemented correctly.

    I’d suggest trying the default theme to confirm this.

    Thread Starter will_pigeon

    (@will_pigeon)

    Hi Esmi,

    Thank you again. Here’s what I can report:

    – your first suggestion does work to prevent the Older/Previous post links from appearing and does not affect tag post listings. I was mistaken. It is possible to see older entries with a tag post listing. I can find no negative result from this change so I have made it. Thank you.

    – I have deactivate and deleted WP-PageNavi, there was no affect good or bad. I have deleted it for now.

    – changing the theme to Default I noticed that the urls are still created (even with WP-PageNavi deleted) however the number of posts in the post lists is now 10, rather than 5 per page. So far I have only 34 posts, therefore they are all listed in the 4 pages. On page 4 there is no “older entries” button and therefore no page 5 to link to (cause of the 404 error).

    So something in my theme is causing only 5 posts to be listed per page instead of 10. I have Where would I locate that setting?

    FYI In Settings > Reading I have “Blog pages show at most” set to 10.

    Thank you for your help so far.

    Will

    It’s possibly a custom query in your theme’s index.php. Try looking for <?php query_posts();?>

    Thread Starter will_pigeon

    (@will_pigeon)

    Thank you again, I found the bit that needed changing, I changed it. Now it works with 10 posts per page and no error. Here’s the code I changed:

    <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=5'.'&paged='.$paged); ?>
    
    	<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>

    I changed showposts=10.

    I also made a change to h1 tag in my index.php. It was previously

    <h1><?php if ( function_exists('get_custom_field_value') ){get_custom_field_value('h1', true); } ?></h1>

    this is the same as the homepage template, which uses a custom field value ‘h1’. I simply changed it to:

    <h1>Recent Posts</h1>

    The final change I want to make is to the title. Is there some conditional function I can use to create a custom title in header.php?

    Something similar to is_front_page()?

    One niggling thing I am wondering; does it matter that we are changing index.php? I mean it doesn’t seem to be used for anything apart from this dynamically created post list, so I guess it is ok to make all these changes?

    Thank you

    Will

    Thread Starter will_pigeon

    (@will_pigeon)

    Ok I made some progress, I found this in Conditional Tags:

    “is_page_template(‘about.php’)
    Is Page Template ‘about’ being used? Note that unlike with other conditionals, if you want to specify a particular Page Template, you need to use the filename, such as about.php or my_page_template.php.”

    So I added this line to my title tag in header.php:

    elseif (is_page_template('index.php')) { echo bloginfo('name');}

    I expected it to work but it doesn’t. Even though it must be using index.php. I’m confused.

    Thanks

    Will

    Thread Starter will_pigeon

    (@will_pigeon)

    Ok so understanding a bit more, I can see that index.php is the last template used if no others are selected. From Page Templates:

    “What Template is used to Display a Particular Page?
    WordPress will look for several template files in your active Theme. The first one it finds will be used to display any given Page. WordPress will look for files in the following order:

    1. The Page’s selected “Page Template”
    2. page.php
    3. index.php”

    As far as I can tell these dynamically created post lists are the only pages that use index.php. Except you say these aren’t pages but post lists, as the content is created dynamically – list of posts in date order. Perhaps the question is – What Template is used to display post lists?

    What I don’t get is how these post lists are just appearing? Sure these four pages of post lists link to each other with the Older/Previous Posts link but what is creating this group of four pages of post lists in the first place?

    My posts are either assigned to the Blog or Portfolio, and it is through these categories and tag searches that the posts are accessed. I haven’t created a page that just list all the posts. Why does it exist?

    The other thing that is bugging me is why is_page_template(‘index.php’) doesn’t seem to work?

    Thoughts appreciated.

    Thank you

    Will

    What Template is used to display post lists?

    Depends on the type of listing being requested. If it’s a listing by category, the template order is category.php -> archive.php -> index.php

    If it’s a listing for a specific month etc, the template order is archive.php -> index.php

    If it’s your site’s front page or it’s main Posts page, the only template used is index.php

    In theory, you need only have an index.php file to display any of these different post listings. The various specialised templates merely offer you the option of displaying the various listing very differently.

    what is creating this group of four pages of post lists in the first place

    If I understand your question correctly, it’s the query – the code that goes and grabs a list of posts from the database based upon specific criteria. The appropriate template then works through the list of post returned from the database using The Loop to display them on the final page(s).

    I haven’t created a page that just list all the posts. Why does it exist?

    Remember that WP creates all of its web pages dynamically. So when it receives a request to display all of your Portfolio posts, it simply looks for the right template do carry out the task.

    The other thing that is bugging me is why is_page_template(‘index.php’) doesn’t seem to work?

    index.php isn’t a page template. It’s a post listing template. In WP Post & Pages are very different entities. To use is_page_template, you’d need to create a custom page template first, then apply it (via the Page Template dropdown) to one of your Pages.

    For your custom title in header.php, try using:

    elseif ( is_home() || is_front_page() ) { echo bloginfo('name');}

    Thread Starter will_pigeon

    (@will_pigeon)

    Fantastic reply!

    Thank you, slowly, slowly the penny is beginning to drop 🙂

    Firstly success in setting the custom title in header.php 🙂

    I used is_home, my front page is a static page (with its own template). Reading your reply and going over the explanation of is_home() and is_front_page() I now understand the difference between the two and what is going on with my site.

    In Settings > Reading > Front page displays’ is set to “A static page”, and Front page is set to my custom “Home” page. The Posts page is not set and shows – Select –

    As my posts are split between my Blog and Portfolio, I could not decide which to set and so left it blank.

    The problem I was having in trying understanding what is going on, is that there isn’t (it seems) a specific request that creates this page of posts. As in a specific request such as show Portfolio posts, or Blog posts, or a Tag posts – I understand how they are created.

    This page of all my posts (or main blog page) is created, it seems, by WordPress even if I haven’t set a Post page.

    Thank you for your help Esmi, I think I have understood everything? perhaps now I should make a decision and set my main blog page!

    there isn’t a specific request that creates this page of posts

    Agreed. It’s the default “show ’em all” query. 🙂

    As I haven’t seen your site, I couldn’t hazard a guess as to how well, or not, it’s working without a Posts page being set but I would recommend that you do set one up. Later on, you may find that some plugins or themes will be looking for this page.

    You don’t have to show the main Post page on your navigation menu if you don’t want to. There are a number of ways of achieving this kind of exclusion but possibly, the simplest would be for you to investigate the custom menu options in Appearance/Menus.

    Thread Starter will_pigeon

    (@will_pigeon)

    Hi Esmi,

    Thank you again for the reply.

    I have created a new page template specifically for showing all posts, and created a “main Post” page selecting this new template. Yes you are correct, I don’t want to show my main Post page in the navigation menu.

    In my 2.8.5 version of WordPress I don’t have an option of Appearance/Menus. Under Appearance my options are; Themes, Widgets, Editor, Add New Themes, My-Theme Options.

    I added the exclude= function to wp_list_pages in my header.php after reading this forum message so it now reads:

    <?php wp_list_pages('title_li=&exclude=1817'); ?> 1817 being the specific ID for my new page.

    I also read another post that suggested it isn’t a good idea to exclude pages this way as it will be lost when upgrading. Is this true?

    I also found a plugin but I haven’t used it. But perhaps this is the best option?

    Having created my new page to show all my posts and successfully excluded it from the navigation menu, I set it as my Post page in Settings > Reading.

    I notice two bits of strange behaviour now:

    1) whatever page is set as the Post page in Settings > Reading the index.php overrides the custom page template set for that page. It doesn’t matter which of my pages I set, this happens.

    2) the “show ’em all” post lists are still created. They have urls http://www.myblog.com/page/1/ to http://www.myblog.com/page/4/ which are distinct from the page I set as my Post page http://www.myblog.com/pageslug/page/1/ to http://www.myblog.com/pageslug/page/4/ However the content is exactly the same, both using index.php.

    Doesn’t this seem odd?

    I think it is probably best I don’t have a Post page set if it is only going to duplicate content?

    Thank you

    Will

    Thread Starter will_pigeon

    (@will_pigeon)

    Ok I found an answer to 1) Posts Page using index.php
    Esmi says “That is the default behaviour when you have a static Home page. Your designated Posts page uses the index.php template file.”

    So the new template I made for showing all posts, I have renamed index.php. (actually there wasn’t that much difference between the old index.php and my template for showing all posts).

    One thing I have noticed is that the code below is not working now the file is index.php:

    <h1><?php if ( function_exists('get_custom_field_value') ) { get_custom_field_value('h1', true);} ?></h1> seems odd that it should not work now that it is index.php but I’m sure there’s a reason!

    Anyway I just get rid of the code and type in the title I want.

    I haven’t found an answer to 2) yet… and I’ve also noticed other unwanted pages being created with urls http://www.myblog.com/page/1/?page_id=dacnfvefcwlekffg to http://www.myblog.com/page/4/?page_id=dacnfvefcwlekffg

    Thanks

    Will

    Thread Starter will_pigeon

    (@will_pigeon)

    more unwanted urls:

    /?page_id=dacnfvefcwlekffg directs to Posts Page

    /?page directs to Front Page
    /?ds directs to Front Page
    /?cd directs to Front Page
    /?cs directs to Front Page

    What are all these urls? what’s creating them?

    Thanks

    Will

    Thread Starter will_pigeon

    (@will_pigeon)

    Ok some more info, it seems that the urls with question marks are Query Strings possibly used for tracking?

    trying to find info on page_ids…

    Thanks

    Will

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘unwanted pages being created – Page of Posts with no wp_title’ is closed to new replies.