[Resolved] Little change in the function generate_do_post_meta_item

Home Forums Support [Resolved] Little change in the function generate_do_post_meta_item

Home Forums Support Little change in the function generate_do_post_meta_item

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1394882
    Raquel Requena López

    Hello:
    Could you put a condition in the function of the file /themes/generatepress/inc/structure/post-meta.php function generate_do_post_meta_item?
    if ( ! function_exists( ‘generate_do_post_meta_item’ ) {
    function generate_do_post_meta_item( $item ) {
    I need to make a theme child and have that function and every time I update the module I get an error and have to add it in the parent theme.
    I have seen that in the file /themes/generatepress/inc/structure/comments.php function generate_comment have done it.
    if ( ! function_exists( ‘generate_comment’ ) ) {
    /**
    * Template for comments and pingbacks
    *
    * Used as a callback by wp_list_comments() for displaying the comments.
    */
    function generate_comment( $comment, $args, $depth ) {
    Thanks

    #1395068
    David
    Staff
    Customer Support

    Hi there,

    what changes are you trying to make to the post-meta.php?
    As we can probably make those changes with Hooks.

    Let us know

    #1396628
    Raquel Requena López

    Hello,
    I have the function in my functions.php file of my child theme and the problem is that it runs before the parent theme.
    When it will call the parent function it gives an error because it already exists.
    The changes are:
    – Hide the date of the post if it’s been more than 9 months
    – Remove links to the author
    However, if you were to put:
    if ( ! function_exists( ‘generate_do_post_meta_item’ ) {
    Before the show, I would solve my problem and it doesn’t disturb the programming at all.
    Thank you

    #1396880
    David
    Staff
    Customer Support

    Instead of overwriting the post-meta function we could use filters to change the content.

    First the Remove Author Links:

    https://docs.generatepress.com/article/generate_post_author_output/#remove-link

    For the post date you could use this filter:

    https://docs.generatepress.com/article/generate_post_date_output/

    #1397010
    Raquel Requena López

    Hello,
    Very interesting these links, I didn’t know that.
    Thanks for the help, I close the topic

    #1397014
    David
    Staff
    Customer Support

    99% of the GP Theme controlled elements have a Filter Hook 🙂

    Glad to be of help.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.