• Resolved rubin-sev

    (@rubin-sev)


    Hello

    I have put a country field in my Custom Post Type

    Field Type -> relationship
    Related Type -> countries

    I don’t know how to have the name of the country in plain text instead of the label
    when i use $pods->field(‘country’) in my code

    is there something like $pods->field(‘country.name’) ?

    I see nothing connected in my internet searches ??

    Any tips ?

    thanks in advance

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @rubin-sev

    Since it’s a relation it’s depending on the type of relationship.

    For taxonomies you can use: country.slug
    For posts you can use: country.post_name

    Cheers, Jory

    Thread Starter rubin-sev

    (@rubin-sev)

    Hi thanks for the answer

    I used countries in the predefined lists option in the related type on a custom post type but sadly country.post_name (or even country.slug) through me an error and return nothing.

    Only $pods->field(‘country’) works but returns only the country labels instead of a full name.

    I looked in the logs and just saw this :
    PHP Warning: Use of undefined constant ICL_LANGUAGE_CODE – assumed ‘ICL_LANGUAGE_CODE’ (this will throw an Error in a future version of PHP)

    the function data_countries() in the file pods->classes->fields->pick.php where there is $data = array(‘label’ => __( ‘name of country’ ),
    seems to be called
    I have not activated any translator plugin ( like polylang or wpml ) and the website is set on English
    it works well in the admin workspace tho, in the selection menu of the country I see all the countries by full name and can selected.

    but in the front end page, I don’t know what $pods->field(‘country’) on a predefined list do exactly but I am in dead end for now I don’t find any clue ??

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @rubin-sev

    Ah right, if you’ve selected a predefined relationship you should be able to use the raw output:

    $pods->field( 'country', array( 'raw' => true ) )

    Cheers, Jory

    Thread Starter rubin-sev

    (@rubin-sev)

    Thanks for your help

    Read via REST API is set as yes ; The response Type is set to “all fields” and depth at 1.

    sadly $pods->field( ‘country’, array( ‘raw’ => true ) )
    return the same thing : the label as a string

    I really don’t know why ??

    Séverine

    Thread Starter rubin-sev

    (@rubin-sev)

    oups I’ve just understood why it did not show the plain name of the country
    I used ->field() not ->display()

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @rubin-sev

    Thanks for reporting back to us and good to hear you’ve found the issue!

    Cheers, Jory

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘country name in plain text instead of label with $pods->field’ is closed to new replies.