This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 5 replies, has 2 voices.

Last updated by Shekhar Bhandari 8 months, 3 weeks ago.

Assigned support staff: Shekhar Bhandari.

Author Posts
January 21, 2019 at 11:53 am #3112154

hofmann-gmbhT

I am trying to create a data strucure of the frontpages on my multisite with their title, permalink, etc. in the language i'm currently in or the subblogs default language if it doesn't have that language.

Link to a page where the issue can be seen: hidden link

Please take a look at the section "Our worldwide locations" and the javascript console. The permalinks give strange results or empty. I assume it has to do with wpml_object_id, which doesn't seem to reset properly on switch_to_blog and get_permalink therefore returns false results. Here is the what i'm doing:

$sites = get_sites();
foreach($sites as $site) {
    $blog_id = $site->blog_id;
    switch_to_blog($blog_id);
    
    $frontpage_id = get_option('page_on_front');
    //$object_id = apply_filters('wpml_object_id', $frontpage_id, 'page');

    $frontpage = get_post($frontpage_id);
    $permalink = get_permalink($frontpage);
    $title = get_the_title($frontpage);

    // create structure, etc.

    restore_current_blog();
}

Here comes the strange thing: in my local environment everythings works fine and as expected (as you can see at the attached image). The wpml_object_id is empty if the page does not exist in that language and get_permalink returns correctly the frontpage of the subblog in its default language. PHP Versions and .htaccess files are the same. Only difference is that on the server the domain is currently on a subdomain.

January 22, 2019 at 3:29 am #3114861

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Thank you for contacting WPML support. I'd be happy to assist you further on this issue.

I can see that you are asking for help on a custom code which is not working on the live site, Unfortunately providing help and debugging custom programming work is beyond the scope of our support.

At this point, I would suggest you consider contacting one of our certified partners from this link: http://wpml.org/documentation/support/wpml-contractors/

Before doing so please have a look also here:
http://wpml.org/documentation/support/wpml-contractors/guidelines-for-people-looking-for-consulting-help/

You will get the custom assistance you need to get on with your project.

Thanks

January 22, 2019 at 8:05 am #3115019

hofmann-gmbhT

🙁

January 22, 2019 at 8:23 am #3115070

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

I understand that this might be frustrating, but since it's a custom code programming we are unable to help you further.

But in the meantime, would you mind letting us know what you really trying to achieve so I can see if we can do this without custom programming?

Look forward to your reply.

Thanks

January 22, 2019 at 10:53 am #3115739

hofmann-gmbhT

Thank you for your efforts trying to help me.

I have a multisite installation. Some blogs are in german, english and spanish language, some only in english or only in german.

I want to display a list of links to all blogs (the frontpages). If i'm on the english version it shows me correctly all permalinks to the english frontpages. When the site has no english version the permalink to the default language is shown. Everything works fine except on the live server, as if some sort of caching happens or the value don't reset properly.

January 22, 2019 at 10:56 am #3115766

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

I am sorry but it seems the only solution here is custom programming work. as there are no any options to show all blog pages of a multisite currently.

Thanks