WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#15435 closed defect (bug) (invalid)

Network blog query returns wrong permalinks

Reported by: developdaly Owned by: nacin
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Permalinks Keywords:
Focuses: Cc:

Description

When querying for posts on network blogs (i.e. a loop for all posts on all network blogs) the permalink of a post is relative to the current site (or top site -- not sure).

The following returns http://xyz.example.com/%post_name% for all posts, no matter what their subdomain is.

So a post usually found at http://abc.example.com/hello-world/ outputs as http://xyz.example.com/hello-world/

query_posts( 'blogid='. $blogid );
while (have_posts()) : the_post();
echo get_permalink();
endwhile;

All other post data is intact. The titles, categories, etc. all match the post. Only the permalink is incorrect.

Change History (10)

comment:1 kapeels3 years ago

  • Cc kapeels added
  • Owner set to kapeels
  • Status changed from new to reviewing

comment:2 developdaly3 years ago

  • Cc patrick@… added

These tickets may be related #12040, #13530.

comment:3 nacin3 years ago

Odd. The rewrite rules won't be reset (as seen in the other two tickets), but the URLs should be fine (based on the original blog's rewrite rules), I imagine.

comment:4 follow-up: SergeyBiryukov3 years ago

I see no evidence whatsoever (neither in Codex nor in source) that query_posts accepts blogid as a parameter. Is query_posts( 'blogid='. $blogid ) a valid example?

comment:5 in reply to: ↑ 4 developdaly3 years ago

Replying to SergeyBiryukov:

I see no evidence whatsoever (neither in Codex nor in source) that query_posts accepts blogid as a parameter. Is query_posts( 'blogid='. $blogid ) a valid example?

I think you're right about nothing being officially supported and I can't find it in the source either. However, it still works ... to an extent. The blogid parameter is being used by query_posts and finding the correct posts. It just isn't writing the permalinks as they should be.

If it isn't "officially" supported it certainly should be.

comment:6 nacin3 years ago

I can't see how. It's probably a plugin.

comment:7 developdaly3 years ago

Indeed it was. How embarrassing.

Can you guys consider adding this parameter in 3.2?

comment:8 nacin3 years ago

You can just switch_to_blog() prior to calling your query.

comment:9 nacin3 years ago

  • Milestone Awaiting Review deleted
  • Owner changed from kapeels to nacin

comment:10 nacin3 years ago

  • Resolution set to invalid
  • Status changed from reviewing to closed
Note: See TracTickets for help on using tickets.