Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#15435 closed defect (bug) (invalid)

Network blog query returns wrong permalinks

Reported by: developdaly's profile developdaly Owned by: nacin's profile 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)

#1 @kapeels
14 years ago

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

#2 @developdaly
14 years ago

  • Cc patrick@… added

These tickets may be related #12040, #13530.

#3 @nacin
14 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.

#4 follow-up: @SergeyBiryukov
14 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?

#5 in reply to: ↑ 4 @developdaly
14 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.

#6 @nacin
14 years ago

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

#7 @developdaly
14 years ago

Indeed it was. How embarrassing.

Can you guys consider adding this parameter in 3.2?

#8 @nacin
14 years ago

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

#9 @nacin
14 years ago

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

#10 @nacin
14 years ago

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