-
AuthorPosts
-
June 3, 2016 at 12:03 am #642322
Hi
I have most of the the meta data to display when I create posts using the ALB. I’m missing only one piece – the posts categories.
I found the code block in this ticket: https://kriesi.at/support/topic/selective-meta-items-shown/#post-637003 but I’ve obviously missing the code that would go into the functions.php file. I tried the following code which I copied from the function #2 to display the tags data, but it did not work:
//For categories:
function custom_shortcode_func3() {
ob_start();
echo the_categories(‘‘.__(‘Categories:’,’avia_framework’).’ ‘);
$output = ob_get_clean();
return $output;
}
add_shortcode(‘the_post_categories’, ‘custom_shortcode_func3’);Can you help me please.
Thanks
LyseJune 4, 2016 at 8:16 am #642866Hey tremblayly,
Thank you for using Enfold.
Did you use the shortcode in a text or code block? https://kriesi.at/support/topic/selective-meta-items-shown/#post-639601
Best regards,
IsmaelJune 4, 2016 at 3:18 pm #642952Hi Ismael,
I used it in a code block with the tags shortcode. All the category shortcode does is echo the shortcode as text.
Thanks
LyseJune 5, 2016 at 2:08 am #643035June 5, 2016 at 2:18 am #643040Hi,
Please find credentials below.
Thank you Ismael.
June 5, 2016 at 6:25 am #643071Hi!
I’m sorry but I think you forgot the url to the site. Please check.
Cheers!
IsmaelJune 5, 2016 at 7:20 am #643080June 6, 2016 at 9:13 pm #643623Hi,
refer to this: https://kriesi.at/support/topic/code-to-insert-in-order-to-show-blog-meta-elements-in-blog-posts-using-avia/#post-468169
Best regards,
AndyJune 7, 2016 at 1:16 am #643724Hi Andy,
I create a shortcode in my functions.php file so in the code block all I need to do is enter the shortcode. That’s what’s not working.
Am I missing something the the shortcode snippet that is causing the shortcode not to work?
Lyse
June 7, 2016 at 11:03 am #643946Hi,
try to use this code inside your functions.php:
function custom_tags_shorcode() { ob_start(); the_tags('<strong>'.__('Tags:','avia_framework').'</strong> '); $output = ob_get_clean(); return $output; } add_shortcode('the_post_tags', 'custom_tags_shorcode'); function custom_categories_shortcode() { global $post; ob_start(); the_terms( $post->ID, 'category', '<strong>Categories: </strong>', ' , ' ); $output = ob_get_clean(); return $output; } add_shortcode('the_post_categories', 'custom_categories_shortcode'); function add_post_categories_after_post_content() { ?> <?php if(!is_singular()) { ?> <div class='custom-blog-meta'> <?php the_tags('<strong>'.__('Tags:','avia_framework').'</strong> '); ?></div> <?php } ?> <div class='custom-blog-meta'> <?php the_terms( $post->ID, 'category', '<strong>Categories: </strong>', ' , ' ); ?></div> <?php } add_action('ava_after_content', 'add_post_categories_after_post_content', 10, 2);
Best regards,
AndyJune 7, 2016 at 3:02 pm #644113Hi Andy,
That code snippet worked but in the code block I use at the end of the blog post to display the tags and categories,
[the_post_tags]
[the_post_categories]the categories don’t start on a new line. How do I get them on a new line. I tried inserting <p> tags but these get ignored.
Thanks
LyseJune 8, 2016 at 11:56 am #644735Hi,
how about </br> instead?
Would you mind providing a precise link to your site, showing the elements in question? We need to be able to inspect them in order to help :)Best regards,
AndyJune 8, 2016 at 4:40 pm #644945Hi Andy,
After reinstalling the theme and my website on a different domain all displays correctly.
Please close this ticket.
Thank you for your support.
Lyse
June 10, 2016 at 5:06 am #645990 -
AuthorPosts
- The topic ‘Add post categories meta data to post created using ALB’ is closed to new replies.