Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plain number field is returned as a string value when using field() #4593

Closed
Digitale-Substanz opened this issue Nov 30, 2017 · 2 comments
Closed
Labels
Closed: Out of scope Status: Need Dev Feedback Waiting on feedback from developer of PR
Milestone

Comments

@Digitale-Substanz
Copy link

I have a CPT pod with a field of type plain number. When I fetch the pod and output the entries using field() (not display()), values of the plain number field are shown as strings rather than integers.

$args = array( 'limit' => -1 );
$pod = pods( 'profiles', $args );
while ( $pod->fetch() ){
    var_dump( $pod->field( 'counter' ), true );
}

The output of var_dump would be str(1) "3" instead of int(3).

The field in concern is also set to Make field "Read Only" in UI in the advanced field settings as the value should be manipulated programmatically.

@JoryHogeveen
Copy link
Member

Might be an enhancement for this field, but keep in mind that metadata is allways a string in WP.
A quick fix would be to parse it as an int: (int) $pod->field( 'counter' )

@JoryHogeveen JoryHogeveen added the Status: Need Dev Feedback Waiting on feedback from developer of PR label Dec 5, 2017
@quasel
Copy link
Member

quasel commented Sep 1, 2018

that's how WordPress works ;) and with php being a loosely typed language ;)

@quasel quasel closed this as completed Sep 1, 2018
@sc0ttkclark sc0ttkclark added this to the Pods 2.7.13 milestone Jun 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed: Out of scope Status: Need Dev Feedback Waiting on feedback from developer of PR
Projects
None yet
Development

No branches or pull requests

4 participants