• Resolved nownomi

    (@nownomi)


    Hello,

    I’ve been researching online and been trying to use exs_entry_meta( bool, bool, etc… ) to display author, date, categories, tags, comments which are controlled by bool(s).

    The question I have is that when I apply this within modified child theme search.php or a category.php page exs_entry_meta() function outputs the bools I designated as ‘TRUE’ and null for the ones designated as ‘FALSE’ as it should.

    However, when I attempted to use the same function, with essentially the same CPT structure and layout within a single_*.php page, nothing is output…

    Things I’ve tried, non exhaustive list:

    1. adjusting the themes template-helpers.php exs_entry_meta() declaration to include, get_the_ID() as an argument, so that the ID may be manually passed through to the function, no output.
    2. Changing my foreach() loop to an if, while conditional loop statement where the other instances of exs_entry_meta() works, no output
    3. changing scope to: Global $post (and $wp_query), so that the foreach() loop has access to the $post->ID, no output
    4. I’ve taken the variable declarations from the search.php and category.php (limited declarations in category.php) to try to troubleshoot or identify what could possibly be wrong
    5. I’ve checked error_log, var_dump(), and print() to see if it would provide any clues. The clue I got was that the function (exs_entry_meta) is not receiving post->ID which is why it is returning ‘NULL’
    6. I’ve rewritten the function as a custom_entry_meta() function which declares all the meta data I am looking for, which does output metadata, however is missing icons and css styling already created for the actual exs_entry_meta() function, while also not being responsive when I turn “off” an argument.

    function custom_entry_meta( $get_the_author = true | false, $get_the_category_list = true | false, $get_the_date = true | false, $get_the_tag_list = true | false, $get_comments_number = true | false ){ echo $get_the_author = get_avatar( get_the_author_meta( ‘ID’ ), $size = ’63’ ); echo $get_the_category_list = get_the_category_list(‘, ‘); echo $get_the_date = get_the_date(); echo $get_the_tag_list = get_the_tag_list(”, ‘, ‘); echo $get_comments_number = get_comments_number();}

    I apologize in advance for the poor formatting, I am not too familiar with this format of posing a question, and I am unable to locate the “code” snippet tool here.

    Any guidance or direction on how to get this function to work within a single_*.php structure would be great, I surmise I may be missing something with the scope or declaration of variables somewhere?

    • This topic was modified 8 months, 4 weeks ago by nownomi.
Viewing 1 replies (of 1 total)
  • Theme Author exstheme

    (@exstheme)

    Hello!
    Thank you for using our theme!

    This function has some advanced logic to check if it was shown earlier to prevent duplication and some actions calling twice. Maybe it is not a best solution to use it in your custom post type by manually code it.

    However, please check our Customizer settings panel for your CPT:

    View post on imgur.com

    View post on imgur.com

    Maybe they will help you.

    It is hard to guess your goals and what exactly your’e trying to achieve, but if you want to code your CPT single page manually – you can look into this functions and grab parts of it and put into your code. At the end of the day it uses the core WordPress functions to show the author, publishing date etc.

    Hope this helps.

    Best regards

Viewing 1 replies (of 1 total)
  • The topic ‘exs_entry_meta() not working in single_*.php’ is closed to new replies.