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

    #642866

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

    #642952

    Hi Ismael,

    I used it in a code block with the tags shortcode. All the category shortcode does is echo the shortcode as text.

    Thanks
    Lyse

    #643035

    Hi!

    Alright. Please post the login details here. We will check it.

    Regards,
    Ismael

    #643040

    Hi,

    Please find credentials below.

    Thank you Ismael.

    #643071

    Hi!

    I’m sorry but I think you forgot the url to the site. Please check.

    Cheers!
    Ismael

    #643080

    Yes I forgot… sorry here it is:

    http://techweb.wpengine.com/ (hosted on WPengine)

    Thanks
    Lyse

    #643623
    #643724

    Hi 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

    #643946

    Hi,

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

    #644113

    Hi 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
    Lyse

    #644735

    Hi,

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

    #644945

    Hi 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

    #645990

    Hi,

    Great! :)

    Best regards,
    Ismael

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Add post categories meta data to post created using ALB’ is closed to new replies.