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

    hello, i was reading an old thread about adding post meta using the layout builder, but seem like some thing is outdated.

    can you please explain on how to add post meta (either using shortcodes or as default for all entries)

    example
    May 2, 2020/ in Uncategorized / by xxxx
    tags: xxxx

    #1211511

    Hey Tarek,
    Sorry for the late reply, this shortcode solution still works, it gives you the title and date as two different shortcodes.
    For a more complete meta shortcode try adding this code to the end of your functions.php file in Appearance > Editor: (code updated with following fix)

    function post_meta_shortcode(){
    	ob_start();
             $the_id = avia_get_the_id();
    	 $taxonomies  = get_object_taxonomies(get_post_type($the_id));
    		$cats = '';
    		$excluded_taxonomies =  apply_filters('avf_exclude_taxonomies', array('post_tag','post_format'), get_post_type($the_id), $the_id);
      
    		if(!empty($taxonomies))
    		{
    			foreach($taxonomies as $taxonomy)
    			{
    				if(!in_array($taxonomy, $excluded_taxonomies))
    				{
    					$cats .= get_the_term_list($the_id, $taxonomy, '', ', ','').' ';
    				}
    			}
    		}
      
    		if(!empty($cats))
    		{
    			echo '<span class="blog-categories minor-meta">'.__('in','avia_framework')." ";
    			echo $cats;
    			echo '</span>';
    		}
      
    	echo "<span class='post-meta-infos' style='margin-top: -25px;'>";
    	$markup = avia_markup_helper(array('context' => 'entry_time','echo'=>false));
    	echo "<time class='date-container minor-meta updated' $markup>".get_the_time(get_option('date_format'))."</time>";
    	echo "<span class='text-sep text-sep-date'>/</span>";
      
    		if ( get_comments_number() != "0" || comments_open() ){
      
    		echo "<span class='comment-container minor-meta'>";
    		comments_popup_link(  "0 ".__('Comments','avia_framework'),
    							  "1 ".__('Comment' ,'avia_framework'),
    							  "% ".__('Comments','avia_framework'),'comments-link',
    							  "".__('Comments Disabled','avia_framework'));
    		echo "</span>";
    		echo "<span class='text-sep text-sep-comment'>/</span>";
    		}
      
    		echo '<span class="blog-author minor-meta">'.__('by','avia_framework')." ";
    		echo '<span class="entry-author-link" '.avia_markup_helper(array('context' => 'author_name','echo'=>false)).'>';
    		echo '<span class="vcard author"><span class="fn">';
    		the_author_posts_link();
    		echo '</span></span>';
    		echo '</span>';
    		echo '</span>';
    	echo '</span>';
    	return ob_get_clean();
      }
      add_shortcode( 'sc_post_meta', 'post_meta_shortcode' );

    and then use the shortcode [sc_post_meta]
    2020-05-09_160225.png
    Best regards,
    Mike

    • This reply was modified 3 years, 11 months ago by Mike. Reason: updated code with following fix
    #1211640

    i am getting the below error. please note that am working with the child theme.

    Notice: Undefined variable: the_id in /home2/monomedia/public_html/wp-content/themes/enfold-child/functions.php on line 10

    Notice: Undefined variable: the_id in /home2/monomedia/public_html/wp-content/themes/enfold-child/functions.php on line 12

    Notice: Undefined variable: the_id in /home2/monomedia/public_html/wp-content/themes/enfold-child/functions.php on line 12

    Notice: Undefined variable: the_id in /home2/monomedia/public_html/wp-content/themes/enfold-child/functions.php on line 20

    #1211641

    Line 10 – $taxonomies = get_object_taxonomies(get_post_type($the_id));
    Line 12 – $excluded_taxonomies = apply_filters(‘avf_exclude_taxonomies’, array(‘post_tag’,’post_format’), get_post_type($the_id), $the_id);
    Line 20 – $cats .= get_the_term_list($the_id, $taxonomy, ”, ‘, ‘,”).’ ‘;

    #1211652

    Hi,
    Thanks for the feedback, perhaps when you copied and pasted the code above you had an error, please include an admin login & FTP access in the Private Content area so we can take a look.
    I tested the code in my child theme before I posted it, so it should work.

    Best regards,
    Mike

    #1211840

    i added a user login in the private area, ftp is disabled for security purposes at the moment, but you can still edit the functions file from the theme editor on wordpress.

    #1212577

    Hi,
    Thanks for the login, I added this to the beginning of the shortcode $the_id = avia_get_the_id(); and now the “notice” is gone, please clear your browser cache and check.

    Best regards,
    Mike

    #1212615

    Thank you, looks good.

    #1212900

    Hi,
    Glad we were able to help, we will close this now. Thank you for using Enfold.

    For your information, you can take a look at Enfold documentation here
    For any other questions or issues, feel free to start new threads in the Enfold forum and we will gladly try to help you :)

    Best regards,
    Mike

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Adding post meta using advanced layout building’ is closed to new replies.