pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.07k stars 264 forks source link

Archive page not working #1959

Closed steve-acet closed 5 years ago

steve-acet commented 10 years ago

EDIT WITH WORKAROUND (by @shelob9 May 22, 2014) A work around for this issue is either to resave permalinks or to turning off rewrite pages, save the Pod and turn them back on. The underlying issue remains unresolved and probably means we are not flushing rewrite rules properly. END EDIT

I have created a basic custom post type, its the same as a normal post type. I have enabled it to have an archive, but the archive page always returns a 404. I have created a template file based on archive.php called archive-blog.php, as blog is the custom post type.

I am trying to do everything using wordpress templates, and the single-blog.php works fine, so not sure why the archive-blog.php isn't working.

Cheers,

Steve

Shelob9 commented 10 years ago

What is the name of you custom post type? Is is blog?

Try removing your custom archive template and see if it renders properly using the theme's archive.php or index.php.

steve-acet commented 10 years ago

Yes, blog is the custom post type. I always seem to get page not found, that's why I tried creating archive-blog.php. I have tried on another site before and couldn't get it to work. I don't know if its just that I am doing something wrong or if there is a bug.

From my understanding I thought archives were part of the hierarchy built into Wordpress. I know I could create a Pods Page and set the url and template, but I wanted to keep it simple.

Shelob9 commented 10 years ago

If you are using a custom post type you should not be using Pods Pages. Do you have the Pods Pages component activated? If so, disable it.

In the pods editor under the "Advanced Options" tab, have you enabled the "Has Archive" option?

steve-acet commented 10 years ago

Hi Josh, Has Archive is on, and Pads component is disabled, but still get the 404 page. I would give you access but its on an Instant Wordpress install so is just local.

steve-acet commented 10 years ago

Just turned off "Rewrite Pages" and my archive is now working.

steve-acet commented 10 years ago

I spoke too soon, it stopped working again after I added custom tags and categories. Even though I have now removed them its still not working.

Shelob9 commented 10 years ago

I think the issue is that you're CPT is called blog which is confusing the default WordPress rewrite rules.

steve-acet commented 10 years ago

Interesting, changing the pod name has worked. Is blog a reserved name?

Shelob9 commented 10 years ago

It's not that it's a reserved name, but WordPress is generally preset to rewrite blog post URLs to domain.com/blog/post-slug so you have a conflict there. You could probably do some rewrites on the posts post type if you wanted, but you're better of staying clear of using 'blog' as the name for a content type as it's hard to know what other issues you'd run into by using that name.

steve-acet commented 10 years ago

With a different post type name I have still been able to use blog in the url, everything seems to be working just fine, though I am not 100% sure how I did it :)

sc0ttkclark commented 10 years ago

Using 'blog' as actual post type name is the culprit here, it's actually a reserved name in WordPress multisite apparently.

sc0ttkclark commented 10 years ago

BTW, this probably would have work with 'blog' as the post type name and a different 'query var' name.

Shelob9 commented 10 years ago

@sc0ttkclark Should I create an issue to prevent using blog as a name of a content type, like we prevent 'name' from being used as the name of a field?

steve-acet commented 10 years ago

Thanks guys, I am going to do a few tests with the page rewrite option, as I was having issues with another post type not named blog that was doing exactly the same.

steve-acet commented 10 years ago

Just tried to create a completely new CPT, called it "tip".

My Permalink settings are set to custom: "/press-releases/%postname%".

The "tip" CPT has archive enabled, but when I use the rewrite pages option the archive and page do not work, I get a 404, but when I disable rewrite pages, they do work.

Steve

rogerlos commented 10 years ago

Perhaps this is unrelated, but I discovered that if I check "rewrite" under advanced options--or leave it checked, I think it may be by default--and don't manually fill out the "Custom Rewrite Slug" field, it would exhibit the same behavior you're noting.

Not sure if this is by design or not; my assumption was that pods would use the "machine name" (or a "sanitized for URLs" version of it) if nothing was filled in, but it does not. I do think pods should fill something into this box automatically if no value is present and the "rewrite" box is checked, or disable the rewrite if the pod is saved and no slug is in the box.

Shelob9 commented 10 years ago

@steve-acet I tried to recreate the issue with rewrites only working when "rewrite pages" option was unchecked. One one, but not the environment I tested in, I saw an issue where enabling rewrite pages caused the archive page to 404, and un checking it fixed the issue. The thing was when I reenabled the "rewrite pages" option everything still worked.

Have you seen similar behavior?

steve-acet commented 10 years ago

@Shelob9 yes, this is what I have observed too.

Shelob9 commented 10 years ago

@steve-acet Can you share your debug information from Pods Admin-> Settings please? I want to compare that with what I have and see if I can find a commonality before I create a formal bug report out of this.

steve-acet commented 10 years ago

WordPress Version: 3.8.1 PHP Version: 5.3.2 MySQL Version: 5.1.46 Server Software: Apache/2.2.15 (Win32) PHP/5.3.2 Your User Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36 Session Save Path: C:\Users\SteveHo\AppData\Local\Temp\Server2Go2400\session\ Session Save Path Exists: Yes Session Save Path Writeable: Yes Session Max Lifetime: 1440 WPDB Prefix: wp WP Multisite Mode: No WP Memory Limit: 40M Pods Network-Wide Activated: No Pods Install Location: W:\Wordpress Sites\www.lcauk.com\InstantWP_4.3.1\iwpserver\htdocs\wordpress\wp-content\plugins\pods/ Pods Tableless Mode Activated: No Pods Light Mode Activated: No Currently Active Plugins: Codepress Admin Columns: 2.1.1 Dynamic Widgets: 1.5.6 e-Commerce Multi Currency Support: 0.8 Google Universal Analytics: 1.3 Kebo - Twitter Feed: 1.4.4 Pods - Custom Content Types and Fields: 2.3.18 Regenerate Thumbnails: 2.2.4 Reinvigorate: 2.0 SecureTrading: 2.x Ultimate Posts Widget: 1.8.1 WP-No-Tag-Base: 1.2.3 WP e-Commerce: 3.8.13.3 WP No Category Base: 1.1.1

steve-acet commented 10 years ago

@Shelob9 just adding that whilst the archive page works, default wordpress pagination does not. I tried using a different name for the rewrite slug as I know using blog could cause issues but it didn't make a difference. Its like the rewrite rules are not working even though the option is turned on.

Shelob9 commented 10 years ago

@steve-acet Has left a lot of good information about this issue in this support thread: http://pods.io/forums/topic/pagination-creating-404/

I'm relabeling this as a bug and re-assigning to @sc0ttkclark

steve-acet commented 10 years ago

I am going to do some more tests using another CPT and see if the problem persists.

Cheers,

Steve

steve-acet commented 10 years ago

I have managed to get it working. I changed the way I reduce the number of pages, I have gone for a pre_get_posts method:

function lca_splog_pre_get_posts( $query ) { if ($query->is_post_type_archive('splog')) { $query->set( 'posts_per_page', 3 ); } }

add_action( 'pre_get_posts', 'lca_splog_pre_get_posts' );

steve-acet commented 10 years ago

This actually gave me issues on my home page where I was displaying the latest splog, to get around this I have used:

function lca_splog_pre_get_posts( $query ) { if (is_post_type_archive('splog') && !is_admin()) { $query->set( 'posts_per_page', 3 ); } }

add_action( 'pre_get_posts', 'lca_splog_pre_get_posts' );

This also prevents the backend display paging in the same way.

Shelob9 commented 10 years ago

We have another user reporting this issue and that it can be resolved by saving WP permalink settings.

http://pods.io/forums/topic/archive-page-using-wordpress-template/#post-181530

@sc0ttkclark Am I right to think that we are failing to flush rewrites rules when this option is updated?

dmlws commented 10 years ago

I'm curious if there has a been a solution worked out that can fix this issue while waiting for 3.0 to be released (which you said should fix the issue). I am having the 404 issue with the pagination but re-saving the permalinks is not fixing the issue. http://southwestopenschool.org/checking/

I have turned off the Pages component as suggested above and 'Has Archive' is enabled.

Thanks.

Shelob9 commented 10 years ago

@dmlws This should not be an issue in Pods 2.4. Do you have the "Rewrite Pages" option checked in the advanced options tab for checking?

steve-acet commented 10 years ago

I think turning off rewrite pages, saving, then turning them back on, will fix it. I haven't tried since I got it working.

dmlws commented 10 years ago

I tried the 'rewrite pages' off/on trick and everything is working. Thanks for your help. I had been trying that with the 'rewrite' option without luck. So close but yet so far!

Shelob9 commented 10 years ago

@dmlws Glad to see you got this worked out and for confirming that @steve-acet's solution worked. I edited the description of this issue to include the workaround, and to restate the actual issue (rewrite rules not being flushed properly.)

StaggerLeee commented 9 years ago

I just had this problem. Difficult to solve because Pods permalinks flush doesnt work allways. Sometime it needs to be flushed from WP side. And if someone manage to click somewhere on front meanwhile you flush everything, Pods related, it goes in evil circle. My problem was not error 404, except when i played to much with rewrite, but archive.php was active all the time, not my archive-mypodstype.php.

Maybe to be on safe side better to solve it for all time with taxonomy-mypodsmaintaxonomy.php. Just copy archive-php content to new file and edit as you need.

Shelob9 commented 9 years ago

@StaggerLeee Is this issue happeing with no other plugins and the default theme?

StaggerLeee commented 9 years ago

Ooo man, give me few days to settle with my project and test it properly.

Last night i tried it with Plugin Organizer and Safe Mode plugins and ruined my widgets, including hours of my work. Custom Pods templates inside widgets. Lucky me, mysql database have this old junk, some kind revisions from widgets. I restored website (need to fix widgets new IDs in css now) but need now to make backup and do it more peacefully.

StaggerLeee commented 9 years ago

Good lesson for the future, put all templates in Pods settings then call them in widgets.

jimtrue commented 5 years ago

@steve-acet Are you still experiencing this particular issue now that we are in 2.7.12? We are closing this ticket as we've had multiple changes with Pods Templates and Archives since this point and I've never heard of this one since this was created.

If you're still having this issue, please comment.