Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview custom post type error #6

Open
NickHeurter opened this issue Mar 6, 2017 · 8 comments
Open

Preview custom post type error #6

NickHeurter opened this issue Mar 6, 2017 · 8 comments

Comments

@NickHeurter
Copy link

I've installed the plugin and it works fine for published posts. But when I tried to preview a custom post type called 'Projects' which is still in concept then the page gives a 404-error. I can see that the preview url, due to the plugin, changes from /?post_type=projects&p=429&preview=true to /?p=429&preview=true and this causes the error.

Is it possible to solve this so also custom post types can be previewed when not published yet? Thanks already for your help!

@nasyrov
Copy link

nasyrov commented Mar 6, 2017

Have you seen anything related in your error log? Could you please check for that.

@NickHeurter
Copy link
Author

Thanks for your comment!

No nothing to see when debugging. What I do see is that the url of the preview link on the admin page /wp-admin/edit.php?post_type=projectsis already changed to /?p=429&preview=true. In the normal situatie this link shouldn't be touched by your plugin or?

@nasyrov
Copy link

nasyrov commented Mar 8, 2017

Hi Nick,

Could you please try to comment out the following:

add_filter( 'post_link', array( $this, 'parse_permalinks' ), 10, 3 );
add_filter( 'post_type_link', array( $this, 'parse_permalinks' ), 10, 4 );

See if it helps to bring back the preview link, if so then the problem lies in parse_permalinks function.

@NickHeurter
Copy link
Author

Hi @nasyrov ,

When I comment out the second line:
add_filter( 'post_type_link', array( $this, 'parse_permalinks' ), 10, 4 );

The preview links works fine but off course the permalink is no longer changed by your plugin.

@nasyrov
Copy link

nasyrov commented Mar 10, 2017

Hi @NickHeurter,

Please try to change

} else { // if they're not using the fancy permalink option
	$permalink = home_url('?p=' . $post->ID);
}

to

}

Basically, comment out the else statement.

@NickHeurter
Copy link
Author

Hi @nasyrov ,

After removing the else statement the preview permalink changes to %category%/%postname%/?preview=true which results in a 404-error...

Thanks for your help, but this doesn't seems to work :)

@Afaq1234
Copy link

Afaq1234 commented May 1, 2018

Hi @NickHeurter,

Please try to change

else { // if they're not using the fancy permalink option
$permalink = home_url('?p=' . $post->ID);
}

to

else {
$permalink = home_url("?post_type=$post->post_type&p=$post->ID");
}

Its work for me... :) Thanks

@NickHeurter
Copy link
Author

Awesome thanks, works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants