Tagged: acf, advanced custom fields, enfold, Portfolio
-
AuthorPosts
-
September 20, 2018 at 9:00 am #1012177
Hello!
i have created custom types in Porftolio items, with Advanced Custom Fields.
I am now looking for how to make them appear in portfolio, for example i made some fields and i would make them appear instead of the post content.
In which php file must I place my code? I do not find the right place! The code has this format: $value = get_field( “text_field” );
Thanks for your help
September 20, 2018 at 4:01 pm #1012369Hey leos,
Thank you for using Enfold.
You may need to edit the includes > loop-portfolio-single.php file or the config-templatebuilder > avia-shortcodes > portfolio > portfolio.php file for that.
Best regards,
IsmaelSeptember 20, 2018 at 6:33 pm #1012421thanks,
after which line of code do I have to enter the php code of advanced custom fields?
The code in question has this formula:
$ value = get_field (“text_field”);Best regards
September 21, 2018 at 5:19 am #1012632Hi,
Do you want to add it on the portfolio grid? Try to put it around line 608 of the portfolio.php file.
$output .= " <div class='grid-entry-excerpt entry-content' $markup>".$excerpt."</div> ";
Edit the loop-portfolio-single.php file if you want to it to display on the single portfolio page.
the_content(__('Read more','avia_framework').'<span class="more-link-arrow"></span>');
Best regards,
IsmaelSeptember 21, 2018 at 10:02 am #1012699Hello!
I tried to edit the portfolio.php file like this:if(!empty($excerpt)) { $markup = avia_markup_helper(array('context' => 'entry_content','echo'=>false, 'id'=>$the_id, 'custom_markup'=>$custom_markup)); $output .= "<div class='entry-content-wrapper'>"; $output .= "<div class='grid-entry-excerpt entry-content' $markup>".$excerpt."</div>"; $output .= "</div>"; //MY CODE $idh = get_field( "idh" ); $convenzione = get_field( "convenzione" ); $data_di_inizio = get_field( "data_di_inizio" ); $durata = get_field( "durata" ); $persone = get_field( "persone" ); $bambini = get_field( "bambini" ); $lingua = get_field( "lingua" ); echo "$idh"; echo "$convenzione"; echo "$data_di_inizio"; echo "$durata"; echo "$persone"; echo "$bambini"; echo "$lingua"; //END MY CODE }
and I tried to edit the loop-portfolio-single.php file like this:
the_content(__('Read more','avia_framework').'<span class="more-link-arrow"></span>'); //MY CODE $idh = get_field( "idh" ); $convenzione = get_field( "convenzione" ); $data_di_inizio = get_field( "data_di_inizio" ); $durata = get_field( "durata" ); $persone = get_field( "persone" ); $bambini = get_field( "bambini" ); $lingua = get_field( "lingua" ); echo "$idh"; echo "$convenzione"; echo "$data_di_inizio"; echo "$durata"; echo "$persone"; echo "$bambini"; echo "$lingua"; //END MY CODE
but in the portfolio page where I would like them to appear I do not see anything. How can I do?
Thanks- This reply was modified 6 years, 1 month ago by leos.
September 21, 2018 at 3:21 pm #1012803Hi,
Try to add the post id using the get_the_ID() function.
$id = get_the_ID(); $idh = get_field( "idh", $id ); $convenzione = get_field( "convenzione", $id );
And you should echo the field without the quotation marks. Wrap it in a p or span tag.
echo "<p>".$idh."</p>"; echo "<p>".$convenzione."</p>";
Best regards,
IsmaelSeptember 21, 2018 at 7:02 pm #1012873Hi,
I tried to do as you told me but nothing appears in the front end. How can I do?
September 23, 2018 at 5:01 pm #1013354Hi,
Please use this code in portfolio.php:
if(!empty($excerpt)) { $markup = avia_markup_helper(array('context' => 'entry_content','echo'=>false, 'id'=>$the_id, 'custom_markup'=>$custom_markup)); $output .= " <div class='entry-content-wrapper'>"; $output .= " <div class='grid-entry-excerpt entry-content' $markup>".$excerpt."</div> "; $output .= "</div> "; //MY CODE $idh = get_field( "idh", $the_id ); $convenzione = get_field( "convenzione", $the_id ); $data_di_inizio = get_field( "data_di_inizio", $the_id ); $durata = get_field( "durata", $the_id ); $persone = get_field( "persone", $the_id ); $bambini = get_field( "bambini", $the_id ); $lingua = get_field( "lingua", $the_id ); $output .= $idh; $output .= $convenzione; $output .= $data_di_inizio; $output .= $durata; $output .= $persone; $output .= $bambini; $output .= $lingua; //END MY CODE }
and in loop-portfolio-single.php use
the_content(__('Read more','avia_framework').'<span class="more-link-arrow"></span>'); //MY CODE $post_id = get_the_ID(); $idh = get_field( "idh", $post_id ); $convenzione = get_field( "convenzione", $post_id ); $data_di_inizio = get_field( "data_di_inizio", $post_id ); $durata = get_field( "durata", $post_id ); $persone = get_field( "persone", $post_id ); $bambini = get_field( "bambini", $post_id ); $lingua = get_field( "lingua", $post_id ); echo $idh; echo $convenzione; echo $data_di_inizio; echo $durata; echo $persone; echo $bambini; echo $lingua; //END MY CODE
Best regards,
PeterSeptember 23, 2018 at 6:08 pm #1013376Hi,
I tried to do as you told me but the fields on the front end of the portfolio post did not appear. Where am I wrong?
I copied the code and pasted it in the respective .php files.Giving you the credentials to access WordPress and files in ftp can you try and see if it works?
I can not understand why it does not work.Thank you
P.s.
Why should I enter the code in 2 different files?September 23, 2018 at 8:07 pm #1013400Hi,
If you’re using the advanced layout builder for your portfolio entries the portfolio templates won’t be loaded/used. As soon as the advanced layout builder is activated another special template is used which does not accept custom php code. However you can use the ACF shortode ( https://www.advancedcustomfields.com/resources/shortcode/ ) to embed your fields – I added a link to the page to the private content field. I used this code
<strong>IDH del booking engine:</strong> [acf field="idh"] <strong>Nome della convenzione/offerta:</strong> [acf field="convenzione"] <strong>Data di inizio:</strong> [acf field="data_di_inizio"] <strong>Durata della convenzione espressa in giorni: </strong> [acf field="durata"] <strong>Numero di persone:</strong> [acf field="persone"] <strong>Numero di bambini:</strong> [acf field="bambini"] <strong>Lingua della convenzione: </strong> [acf field="lingua"]
Best regards,
PeterSeptember 23, 2018 at 11:29 pm #1013428Hi,
Thanks a lot, turning off the advanced editor in fact it works!
If I wanted to view the custom fields also in the pages and blog articles in which .php files should I enter the code?
In that case, do I still have to disable the advanced editor as in the portfolio articles?Thank you
September 25, 2018 at 6:53 am #1014015Hey!
Yes, you have to disable the advance layout builder. You can modify the includes > page.php and the includes > loop-single.php file if you want the custom fields to display on pages and posts.
Best regards,
IsmaelSeptember 25, 2018 at 11:08 am #1014130Thank you!
September 25, 2018 at 11:27 am #1014142Hi!
Glad we could help you :)
Regards,
Peter -
AuthorPosts
- You must be logged in to reply to this topic.