• Resolved kreattivo

    (@kreattivo)


    Hi, how do I check the language of source post type, using WPML?
    On form (frontend) I need only posts of the current language.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @kreattivo

    Thank you very much for using our plugin. In this case, you can read the posts associated to a language directly from the database with a query similar to:

    SELECT * FROM {wpdb.posts} as posts
    INNER JOIN {wpdb.prefix}icl_translations post_trans
    ON posts.ID = post_trans.element_id
    WHERE post_trans.language_code = 'The language code here';

    Learn more about the WPML database structure by visiting the following link:

    https://wpml.org/documentation/support/wpml-tables/

    If you have other questions about the WPML database structure, you can contact the WPML developers team.

    Best regards.

    Thread Starter kreattivo

    (@kreattivo)

    Sorry for the confusion, but I’m using your plugin “Data Source for Contact Form 7” and I want to know how to configure the select field on a form, gettin post for the specified language

    Plugin Author codepeople

    (@codepeople)

    Hello @kreattivo

    Yes, I know.

    Our plugin includes two controls: “Recordset”, and “r”Recordset field link”. The “Recordset” control reads the information from the data source (In this case, the database), and the “Recordset field link” creates the relationship between “Recordset” and “Dropdown” fields.

    For example, assuming your website languages are en and es, a possible structure would be:

    
    <p>Languages:<br>[select languages "en" "es"]</p>
    <p>Posts:<br>[select posts]</p>
    
    [cf7-recordset id="posts_data" type="database" query="SELECT posts.* FROM {wpdb.posts} as posts INNER JOIN {wpdb.prefix}icl_translations post_trans ON posts.ID = post_trans.element_id WHERE post_trans.language_code = '{field.languages}';"]
    
    [cf7-link-field recordset="posts_data" field="posts" value="ID" text="post_title"]

    Best regards.

    Thread Starter kreattivo

    (@kreattivo)

    Thank you very much. I solved with a whole database query. TOP

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WPML and language condition’ is closed to new replies.