Support » Networking WordPress » get_permalink isn't multisite aware

  • Resolved salientdigital

    (@salientdigital)


    I have a network of 15 sites, running Domain Mapper for each at its own unique URL. Say DomainA.com is my default domain and I have DomainB.com through DomainO.com.

    I have a custom contact form widget that generates its action attribute like so:

    <form id="contact_widget" method="post"
    action="<?php get_permalink(get_page_by_title('Send Contact')->ID) ?>">

    which works only on the default site…

    In short I just discovered that get_permalink ignores the multisite domain that it is on, get_page_by_title only looks in wp_posts (not the domain’s wp_2_posts or wp_3_posts, etc.

    How do I get a permalink for a post title ‘Send Contact’ on the same domain I am on within a multisite, or a permalink to a post on another site in the network?

    It doesn’t seem possible without writing my own SQL to find the post manually with something like

    $table = "wp_".get_current_blog_id()."_posts";

    It seems this would be a useful feature and I am rather surprised it is missing… any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    Lead Plugin Wrangler

    That’s not correct… Get_permalink should be aware, unless you’re calling it from a separate site.

    Andrea Rennick

    (@andrea_r)

    Customer Care at Copyblogger Media and Studiopress

    Your code is incorrect.

    Yeah – weird. After restarting Apache it worked fine :-/

    I have a related problem. When I try switch_to_blog() to the main site and then get_permalink or directly with just get_blog_permalink() I get the URL without the /blog prefix that the main site is supposed to have.
    This only happens when I try to access a permalink for the main blog from a different blog, but when calling it from within the main blog it works okay.

    I just realized, the issue above only happens with custom post types, regular posts seem to be fine.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘get_permalink isn't multisite aware’ is closed to new replies.