Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#32385 closed defect (bug) (duplicate)

Adding Post Formats Support to Pages breaks the Preview Changes functionality

Reported by: bduclos's profile bduclos Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Post Formats Keywords:
Focuses: Cc:

Description

When I add Post Formats Support to pages using the code:

add_post_type_support( 'page', 'post-formats' );

clicking on the Preview Changes button while editing a page leads to "Page not Found".

The url generated looks like

http://domain.com/?page_id=457&preview_id=457&preview_nonce=9f71d1c7df&post_format=standard

If I remove the "&post_format=standard" at the end of the url it works.

(Tested with Twenty Fifteen, no plugins activated)

Change History (15)

#1 @valendesigns
9 years ago

  • Keywords needs-patch needs-unit-tests added

I'll take a look at this tomorrow, unless someone gets around to it before me.

#2 @johnbillion
9 years ago

  • Keywords dev-feedback added
  • Version changed from 4.2.2 to 3.1

I believe that post formats are intended only for Posts. You may well come across other issues with adding post format support to other post types.

#3 @chriscct7
9 years ago

  • Keywords dev-feedback removed

Possibly invalid. The post preview shows you the single post view selected on the edit page. When you're previewing a post, where let's say you selected gallery on the edit post page, regardless of what you pass into &post_format=, you will still be previewing the gallery format. You can verify this on 2015 by looking at the outputted post format name on the bottom of the post. Trying to change the post_format in the URL doesn't actually do anything.

#4 @chriscct7
9 years ago

  • Keywords dev-feedback added

#5 @chriscct7
9 years ago

Here's a video actually showing this behavior: https://db.tt/KzfmNPpr

You can't change the post format used on a preview page through the url as depicted even for posts

This ticket was mentioned in Slack in #core by chriscct7. View the logs.


9 years ago

#7 follow-up: @johnbillion
9 years ago

I don't think bduclos is trying to change the post format preview via the post_format query arg. They pointed out that the generated preview URL contains this query var, and that it causes a 404 (I've not checked, but I bet post formats are intrinsically tied to Posts).

Last edited 9 years ago by johnbillion (previous) (diff)

#8 in reply to: ↑ 7 ; follow-up: @chriscct7
9 years ago

Replying to johnbillion:

I don't think bduclos is trying to change the post format preview via the post_format query arg. They pointed out that the generated preview URL contains this query var, and that it causes a 404 (I've not checked, but I bet post formats are intrinsically tied to Posts).

They don't for me. It only 404's when I manually add the &post_format= to the end

#9 in reply to: ↑ 8 @johnbillion
9 years ago

  • Keywords reporter-feedback added; needs-patch needs-unit-tests dev-feedback removed

Replying to chriscct7:

They don't for me. It only 404's when I manually add the &post_format= to the end

Confirmed.

@bduclos Can you test this behaviour with all your plugins deactivated (except the piece of code which adds post format support to Pages of course), and one of the default themes (eg. TwentyFifteen) active please?

#10 follow-up: @bduclos
9 years ago

I've tested again on a fresh WordPress install, still got the issue as shown on the following video:
https://www.dropbox.com/s/ao4d1hdirkob5uq/page_post_formats_preview.mp4?dl=0
The video posted above by @chriscct7 shows the "Preview changes" functionality on a Post while the issue is with Page.

#11 in reply to: ↑ 10 ; follow-up: @chriscct7
9 years ago

  • Keywords reporter-feedback removed

Replying to bduclos:

I've tested again on a fresh WordPress install, still got the issue as shown on the following video:
https://www.dropbox.com/s/ao4d1hdirkob5uq/page_post_formats_preview.mp4?dl=0
The video posted above by @chriscct7 shows the "Preview changes" functionality on a Post while the issue is with Page.

The video above demonstrates a different behavior. I'm only able to replicate your reported behavior when the page is published and then you attempt to preview it.

I think I've solved this. Will post the solution in a the next few hours

#12 in reply to: ↑ 11 @bduclos
9 years ago

Replying to chriscct7:
I've tried to filter the preview url using the preview_post_link filter but still having some issues.
Did you find a solution?

#13 follow-up: @rmccue
9 years ago

  • Keywords close added

This feels like it's not really a bug to me, and that adding post format support to non-posts is generally a Bad Idea. Thinking close, unless the query var issue is an actual bug we need to fix?

#14 @chriscct7
9 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #20438.

So this is actually a duplicate of https://core.trac.wordpress.org/ticket/20438

Your code should be:

add_action( 'init', function() {
	add_post_type_support( 'page', 'post-formats' );
	register_taxonomy_for_object_type( 'post_format', 'page' );
}, 11 );

as you have to register the taxonomy for the page object

#15 in reply to: ↑ 13 @bduclos
9 years ago

Replying to rmccue:
Do you also consider that adding post format to custom post type (e.g. portfolio) is a bad idea?

Note: See TracTickets for help on using tickets.