Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #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

    #1012369

    Hey 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,
    Ismael

    #1012421

    thanks,

    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

    #1012632

    Hi,

    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,
    Ismael

    #1012699

    Hello!
    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, 3 months ago by leos.
    #1012803

    Hi,

    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,
    Ismael

    #1012873

    Hi,

    I tried to do as you told me but nothing appears in the front end. How can I do?

    #1013354

    Hi,

    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,
    Peter

    #1013376

    Hi,

    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?

    #1013400

    Hi,

    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,
    Peter

    #1013428

    Hi,

    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

    #1014015

    Hey!

    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,
    Ismael

    #1014130

    Thank you!

    #1014142

    Hi!

    Glad we could help you :)

    Regards,
    Peter

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.