Tagged: 

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #649203

    Hi there,

    I am happy using Enfold for several years now.
    More or less out-of-the-box and only changing the content and settings.

    But now I want to enhance one of my website with some extra (custom) fields.
    When this is answered anywhere I am fully sorry, but I searched and did not find a clear answer ;-)

    I know how to add custom fields to posts.
    Now I want to show that fields on my archive and single posts pages.
    I read a lot about using the advanced layout builder and understand that.
    But what is the best way to show those fields on the frontend pages?

    Do I really have to change the single.php file to show those extra fields?
    (Of coarse I would have copied that file to my child theme !!)
    Or is there any other way? Perhaps via the avia framework functions?

    I am concerned about the upgrades of WordPress / Enfold.
    Whenever the master single.php file of Enfold (not child) will be upgraded (e.g. new PHP functions), my changes single.php will perhaps no longer work.

    Thanks in advance,
    Jan Lucas

    #650550

    Hey JB_Walton,

    Thank you using Enfold.

    Yes, you have to add the custom fields in the single post template (includes > loop-index.php file). These links might help: .

    https://codex.wordpress.org/Custom_Fields

    Best regards,
    Ismael

    #650736

    Hi Ismael,

    Thanks for your reply.
    I have been looking around and figured out the way I want it:

    • I want to use a typical enfold / avia solution.
    • I use a child theme, so I added the shortcodes code in functions.php of the child theme.
      add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1);
      function avia_include_shortcode_template($paths)
      {
      	$template_url = get_stylesheet_directory();
          	array_unshift($paths, $template_url.'/shortcodes/');
      
      	return $paths;
      }
    • I want to add a content element (post-custom-field) to add a special element in the avia layout builder. Therefore I created a special post_custom_fields.php in the directory enfold-child/shortcodes.

    I want to choose one of the available custom fields of that post in a drop down list.
    So I try to create that drop-down list, and need to fill an array with the meta-key of each custom field. Choosing the meta-key should result in showing the meta-value in frontend. Styling will be no problem.

    I have problems creating the dropdown list now.
    I only see the “Select One” in my dropdown list.

    My code at the moment:

    			function popup_elements()
    			{
    
    				/* jan */
    				/* add dropdown list for custom fields */
    
    				$custom_fields = get_post_custom();
    				$all_custom_fields[ 'Select One' ] = null;
    
    				if ( !empty($custom_fields) && !is_wp_error ($custom_fields) ) :
    					foreach ($custom_fields as $custom_field ) :
    						$all_custom_fields [meta_id] =  "__('$custom_field->meta_key', 'avia_framework') => '$custom_field-meta_key'";
    					endforeach;
    
    			  endif;
    
    				$this->elements = array(
    
                        array(	"name" 		=> __("Do you want to display custom post fields?", 'avia_framework' ),
                            "desc" 		=> __("Do you want to display custom post fields available in the post?", 'avia_framework' ),
                            "id" 		=> "cust_field_name",
                            "type" 		=> "select",
                            "std" 	=> "Quotes",
    												"subtype" => $all_custom_fields
    
    											),
    
    

    I’m still diving into the code, to figure out the problem.
    But perhaps you can see the problem.

    EDIT:
    I want to access all custom fields from the current post, but the post_ID of the current post equals NULL.
    I searched and saw that that global variables of WordPress do not work in the Avia Layout Builder.
    Is that anyhow possible?

    Thanks again,
    Jan

    • This reply was modified 8 years, 5 months ago by JB_Walton.
    #651833

    Hi,

    I’m sorry but this will require modifications that are outside the scope of support. Please contact codeable or hire a freelance developer. An easy workaround is to modify the loop-index.php file. Create a change log in case you update the theme.

    Best regards,
    Ismael

    #651836

    Hi JB,

    We’ve done this for numerous clients before on the Enfold Theme. I’d recommend creating a Child Theme for Enfold if you are worried about losing your changes to single.php.

    You can download the Child Theme for Enfold here: http://kriesi.at/documentation/enfold/using-a-child-theme/

    If you’d like professional help, you can check out a site like Codeable who specialize in freelance WordPress outsourcing OR if you’re looking for a more robust web design firm like Story Block, feel free to shoot me a message.

    Have a great night!

    #651999

    Hi,

    Thanks for the answers.
    I understand, that what I am asking, is beyond the scope of support.

    To be clear:
    – I am focussing on backend right now. Frontend will be nest step (loop-index.php).
    – I do want to use the Avia Framework.
    – Everything has to be coded in the child theme.

    I have built many websites using Enfold, and first thing after installation Enfold is creation of that Child Theme.
    All modifications to the theme, that I make, are doen in the child theme.

    I will look into it myself.
    One question, though: Is there any documentation on the Avia Framework.
    Explanation of the array structure and the typical usage in Avia elements would be of great help.


    @Storyblock
    : Thanks for the offer, but I am not capable of hiring people at this moment.

    Thanks again,
    Jan

    • This reply was modified 8 years, 5 months ago by JB_Walton.
    #652795

    Hi,

    One question, though: Is there any documentation on the Avia Framework.
    Explanation of the array structure and the typical usage in Avia elements would be of great help.

    Unfortunately, the documentation is not that comprehensive at the moment. You can only find basic tutorials, filters and hooks in the documentation: http://kriesi.at/documentation/enfold/

    Best regards,
    Ismael

    #652944

    Hi Ismael,

    Thanks.
    This topic can be closed.

    Jan

    #653270

    Hi Jan,

    Great, thanks for letting us know.

    Best regards,
    Rikard

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Showing Custom Fields on Single Post pages’ is closed to new replies.