WPML and Pods 2.0 #844

Closed
diogopms opened this Issue Dec 8, 2012 · 13 comments

Comments

Projects
None yet
5 participants

diogopms commented Dec 8, 2012

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 commented Dec 8, 2012

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'

Contributor

unknownnf commented Dec 9, 2012

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 commented Dec 9, 2012

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...

@ghost ghost assigned sc0ttkclark Dec 28, 2012

Owner

sc0ttkclark commented Dec 28, 2012

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.

Owner

sc0ttkclark commented Jan 6, 2013

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

@ghost ghost assigned sc0ttkclark Jan 6, 2013

sulco commented Jan 8, 2013

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)

Owner

sc0ttkclark commented Jan 8, 2013

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

sc0ttkclark added a commit that referenced this issue Jan 8, 2013

pieterc commented Jan 14, 2013

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

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

Thank's

Owner

sc0ttkclark commented Jan 14, 2013

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

Owner

sc0ttkclark commented Jan 25, 2013

With caching enabled, this should now be resolved.

Owner

sc0ttkclark commented Jan 25, 2013

Fixed by #974 and 6dbeb23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment