Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

WPML and Pods 2.0 #844

Closed
diogopms opened this Issue · 13 comments

5 participants

@diogopms

I'm having some difficulty integrating wpml and posds 2.0 using custom post types.

First:

1º I created a post type on pods 2.0 and called "propostas"(http://img600.imageshack.us/img600/1567/screenshot20121208at617.png)

2º I add 3 posts in different languages:

Post with Title : Test EN => English
Post with Title: Teste PT => Portuguese
Post with Ttitle: Test FR => Frech

3º I created a page template and a put this code:

   //THIS CODE ONLY DISPLAY POST TYPE OF SELECTED LANGUAGE
    query_posts( array( 'post_type' => 'propostas','posts_per_page' => -1 ) );
        if (have_posts()) :
            while (have_posts()) : the_post();
                echo get_the_title() . "<br>";
                endwhile;
            endif; 

If i selected English language appear only the post Test EN.
If i selected Portuguese language appear only the post Test PT.
If i selected French language appear only the post Test FR.

//PODS CODE..DON'T WORK...LIST ALWAYS ALL POST...
    $pods =  pods( 'propostas' );   
    $params = array(
        'orderby' => 'name ASC',    
        'limit' => 15
    );
    $pods->find($params);
    while ($pods->fetch()) {
        echo $pods->display('name') . "<br>";
    }

If i selected English language appear all posts
If i selected Portuguese language appear all posts
If i selected French language appear all posts

(I put this code in a page template associated to a wordpress page)

http://pastebin.com/15Yh7es8

Video showing the error: http://www.youtube.com/watch?v=2Gkk9xXLuIQ

Paste bin Page test1: http://pastebin.com/AVx5VWwf

After commit bb2ec35:

Video: http://www.youtube.com/watch?v=gjEwjdSL6kU

Thank's

@diogopms

Database Error; SQL:

SELECT DISTINCT `t`.* FROM `wp_posts` AS `t` LEFT JOIN `wp_icl_translations` AS `wpml_translations` ON `wpml_translations`.`element_id` = `t`.`ID` AND `wpml_translations`.`element_type` = 'post_propostas' AND `wpml_translations`.`language_code` = 'pt-pt' LEFT JOIN `wp_icl_languages` AS `wpml_languages` ON `wpml_languages`.`code` = `wpml_translations`.`language_code` AND `wpml_languages`.`active` = 1 LEFT JOIN `wp_postmeta` AS `wpml_languages` ON `wpml_languages`.`meta_key` = 'wpml_languages' AND `wpml_languages`.`post_id` = `t`.`id` WHERE `t`.`post_status` = "publish" AND `t`.`post_type` = "propostas" AND `wpml_languages`.`code` IS NOT NULL ORDER BY `t`.`post_title` ASC, `t`.`menu_order`, `t`.`post_title`, `t`.`post_date` LIMIT 0, 15;

Response: Not unique table/alias: 'wpml_languages'

@unknownnf
Collaborator

I'm guessing you will have to pass a where clause in $params that differentiates between languages. Something like

$params = array(
    'orderby' => 'name ASC',
    'limit' => 15,
    'where' => "language = '{ICL_LANGUAGE_CODE }'"
);

I'm not really sure how WPML does this in query_posts since I don't use the plugin myself, however something like this should work.

@diogopms
Database Error; SQL: SELECT DISTINCT `t`.* FROM `wp_posts` AS `t` WHERE language = 'en' AND `t`.`post_type` = "ofertas" ORDER BY `t`.`post_title` ASC, `t`.`menu_order`, `t`.`post_title`, `t`.`post_date`; Response: Unknown column 'language' in 'where clause'

I confirm in wp_posts don't exist a column called language...

@sc0ttkclark sc0ttkclark was assigned
@sc0ttkclark
Owner

Did you get around this? Sorry, I was out of the country at the start of this month and then the holidays hit shortly after.

@sc0ttkclark
Owner

Will do some more testing locally and see if anything got messed up from a 2.1+ release.

@sc0ttkclark sc0ttkclark was assigned
@sulco

I confirm having the same error in latest (2.1) release
(in fact I came across this issue report after googling the error diogopms writes about)

@sc0ttkclark
Owner

Still working through this, this may be a caching issue on our end.

@pieterc

The problem is gone with your fix @sc0ttkclark . Confirmed. :)

@diogopms

it's working, but i need to clear pods cache every time i changed language.

Thank's

@sc0ttkclark
Owner

@diogopms Exactly, our transients/caching needs to be prefixed by the current language code (if WPML is active). Working on that next.

@sc0ttkclark
Owner

With caching enabled, this should now be resolved.

@sc0ttkclark
Owner

Fixed by #974 and 6dbeb23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.