Skip Navigation

[Gelöst] Permalinks for new CPT not working

This support ticket is created vor 7 Jahre, 7 Monate. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 6 Antworten, has 2 Stimmen.

Last updated by ashleighP vor 7 Jahre, 7 Monate.

Assisted by: Beda.

Author
Artikel
#428964

I am trying to: Create pages for a new CPT

I visited this URL: charmcat.net/account/event/timeline/test-timeline/

I expected to see: when not logged in, users should see a message that says "this isn't yours!" and a login link.

Instead, I got: 404 not found

Using the GUID charmcat.net/?p=7917 redirects properly but then I get the same result... not found

Tried:
- resaving permalinks
- clearing all caches
- using another browser

Also:
- all posts in that CPT have the problem
- no other CPT is affected

#429186

How do you restrict the access to not logged in users?

Types will nto help you do this.

Do you use Access?

Then you can choose what to display in Toolset > Access > your_post_type > control with Access > what to display if the user has no permissions (the little edit icon next to the Checkbox for the ability)

To display a Login Form instead you will either need to apply a Content Template holding that Shortcode or some HTML conditional

This all seems not to be done yet, as you say you can actually call the login form, and that is strange, I might be missing a step.

Can you elaborate how you set things up?

#429271
what a non-logged in user should see.png

My content template for the page is set up like this:

<!--------------------------------------------------------------
------Show only if user is logged in; or if user is admin------
--------------------------------------------------------------->
[wpv-conditional if="( '[wpv-current-user]' eq '[wpv-post-author id='$event']' ) OR ( '[wpv-current-user info="role"]' eq 'administrator' )"]

<!--Page Content-->

[/wpv-conditional]<!--End show only if user is logged in-->

<!-------------------------------------------------------------
-------------Show if author/user is not logged in-------------
--------------------------------------------------------------->
[wpv-conditional if="( '[wpv-current-user]' ne '[wpv-post-author id='$project']' ) AND ( '[wpv-current-user info='role']' ne 'administrator' )"]
<h1>This isn't yours!</h1>
<!--Show their projects if logged in-->
[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'true' )"]
<p>Check out your own projects.</p>
[wpv-view name="my-projects-view"]
[/wpv-conditional]
<!--End their projects-->

<!--Show if guest-->
[wpv-conditional if="( '[wpv-current-user info='role']' eq '' )"] 
<p>If you'd like to see a current project, please log in.</p>
[wpv-login-form allow_remember="true"][/wpv-conditional]
<!--End if guest-->

[/wpv-conditional]
<!--End show if user is not logged in-->

I am not using Access because Access does not have the capability of restricting access only to the author of the current page. It can only restrict access based on roles. In Access, the CPT is set to show to everyone, so it shouldn't be getting a 404 page ever.

I use this exact code on other CPTs and it works perfectly, so the code in the content template isn't the problem.

I tested by making another new CPT and I can't recreate the problem. I may have to just start over...

#429340

A content Template has no effect on the accesibility of an URL.

Wether your restrict CONTENT in that Template or not, the URL is always the same and accessible, or, of done so, repsecting the Access Settings.

A simple test is to unassign the Template from the post, and navigate to it.

The 404 will still happen, because Content Templates have no effect on a URL.

I also see you did use the default "display name" for the Current user.

I would suggest to use the ID or login name, it's more unique.

It is very strange that you are able to see the same Post/Page with another Content Template, since Content Templates have no effect on the URL itself.

I suggest to delete that Content Template, after copy paste the code and create a new one. That's a 5 minute or less process.

But you will need to adjust your Conditionals, I suggest to use the User ID or other attributes than the display name here.

#435873

"It is very strange that you are able to see the same Post/Page with another Content Template, since Content Templates have no effect on the URL itself."

I'm actually not able to. I applied other layouts and content templates I know work and I still get the 404 on the timeline post type.

When I apply the timeline content template and layout to other CPTs I get the white screen of death. My error log says:

"Object of class WP_Post could not be converted to string in /nas/content/live/charmcat/wp-includes/taxonomy.php on line 3769" which is this function

/**
 * Retrieves the taxonomy relationship to the term object id.
 *
 * @since 2.3.0
 *
 * @param int    $id       Term object ID.
 * @param string $taxonomy Taxonomy name.
 * @return bool|mixed Empty array if $terms found, but not `$taxonomy`. False if nothing is in cache
 *                    for `$taxonomy` and `$id`.
 */
function get_object_term_cache( $id, $taxonomy ) {
	return wp_cache_get( $id, "{$taxonomy}_relationships" );
}
#435902

Okay, so I completely started over... deleted the post type and redid it all and now it's working.

#435908

Well, I finally figured out what triggered the 404. I updated the settings in the new cpt one by one and when I tried to put in a url rewrite "account/event/timeline" it triggers a 404 but if I change it to anything else it works.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.