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:

enter image details here

then I have conditional fields, so if "PA" is selected then it shows the PA field:

 </ P> <p> <strong> My question is: </ strong> </ p> <p> How do I have a different selection box of these conditional fields for options. </ P> If they are added to a statement so that the correct field is shown based on the supplied content? </ P> <p> Example </ p> <pre> <code> If job_slari was selected as

This approach should work in my example, the main selector field where you pay per year, competitive , Category, etc., it's called salary_type .

Then I got 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'.

Then we can test appropriate values ​​and output to HTML based on 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 ">

PHP

  & 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

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -