php - Wordpress Advanced Custom Fields within an if statement -
I am trying to use the ACF in separate pay amounts for the Job Listing Board.
Example:
Choose the box option in ACF for the pay type ("Competitive", per day, per year etc) . It looks like:
then I have conditional fields, so if "PA" is selected then it shows the PA field:
This approach should work in my example, the main selector field where you pay per year, competitive , Category, etc., it's called Then I got Then we can test appropriate values and output to HTML based on PHP salary_type .
per_annum . On being displayed, selection is being made on conditional
salary_type on 'per year'. And finally
per_annum_range_low and
per_annum_range_high , both of which are being conditional on 'range per year'.
salary_ type selection. Alternatively, you can check the existence of those areas but I think it is a bit cleaner and you can skip adding an additional area for ">
& lt ;? Php if (get_field ('salary_type')) {// First we see that the salary_type field exists or not $ Selection = get_field ('salary_type'); // If we store our value in the form of a '$ selection' ($ selection === 'comp') {// We check that it was selected by looking at its label 'echo' & lt; P & gt; . 'Competitive' '& lt; / P & gt; '; } And if ($ selection === 'perannum') {// ACF allows you to store both a selection both in one price (in this case, 'Pernmann') and as a label ('per year') Is the user who sees.) Echo '& lt; P & gt; . Get_field ('per_annum') 'per year & lt; / P & gt; '; } And if ($ selection === 'perannumrange') {echo '& lt; P & gt; From 'Get_field (' per_annum_range_low ')' My service ' Get_field ('per_annum_range_high') 'per year & lt; / P & gt; '; // and then you want your output and any HTML markup} Else {echo & lt; P & gt; No salary information given & Lt; / P & gt; '; // if they do not make any selection}}? & Gt;
Comments
Post a Comment