[Resolved] Unable to communicate back with site to check for fatal errors

Home Forums Support [Resolved] Unable to communicate back with site to check for fatal errors

Home Forums Support Unable to communicate back with site to check for fatal errors

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • #2395688
    MD Tohidul

    Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.

    After updating the theme, my previous all saved settings gone away. Anyway, I want to show the last updated date of my article.

    How can I do this?

    #2395739
    Leo
    Staff
    Customer Support

    Hi there,

    Anyway, I want to show the last updated date of my article.

    Are you using the block editor?

    If so using a block element would be the easiest method:
    https://docs.generatepress.com/article/block-element-post-meta-template/

    #2395767
    MD Tohidul

    I found this method is very complex.

    I used the following code previously in the PHP Editor, and my work done like magic. How can I do this again?

    add_filter( ‘generate_post_date_output’, function( $output, $time_string ) {
    $time_string = ‘<time class=”entry-date published” datetime=”%1$s” itemprop=”datePublished”>Published on: %2$s</time>’;

    if ( get_the_date() !== get_the_modified_date() ) {
    $time_string = ‘<time class=”entry-date updated-date” datetime=”%3$s” itemprop=”dateModified”>Last Updated on: %4$s</time>’;
    }

    $time_string = sprintf( $time_string,
    esc_attr( get_the_date( ‘c’ ) ),
    esc_html( get_the_date() ),
    esc_attr( get_the_modified_date( ‘c’ ) ),
    esc_html( get_the_modified_date() )
    );

    return sprintf( ‘<span class=”posted-on”>%s</span> ‘,
    $time_string
    );
    }, 10, 2 );

    #2395772
    Leo
    Staff
    Customer Support

    That code should still work. Have you tried it?

    #2395803
    MD Tohidul

    Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.

    There is error when tried the code !

    #2395810
    Leo
    Staff
    Customer Support

    Where are you adding the code?

    #2396162
    MD Tohidul

    Appearance >> Theme File Editor >> Functions.php

    #2396442
    David
    Staff
    Customer Support

    Hi there,

    First off – DO NOT make edits the Themes functions.php. Any changes you make will be lost when the Theme is updated, and you risk breaking the site.

    When adding PHP you should read this document:

    https://docs.generatepress.com/article/adding-php/

    #2396443
    MD Tohidul

    Then where should I put the code in the web to show the last updated date of my post?

    add_filter( ‘generate_post_date_output’, function( $output, $time_string ) {
    $time_string = ‘<time class=”entry-date published” datetime=”%1$s” itemprop=”datePublished”>Published on: %2$s</time>’;

    if ( get_the_date() !== get_the_modified_date() ) {
    $time_string = ‘<time class=”entry-date updated-date” datetime=”%3$s” itemprop=”dateModified”>Last Updated on: %4$s</time>’;
    }

    $time_string = sprintf( $time_string,
    esc_attr( get_the_date( ‘c’ ) ),
    esc_html( get_the_date() ),
    esc_attr( get_the_modified_date( ‘c’ ) ),
    esc_html( get_the_modified_date() )
    );

    return sprintf( ‘<span class=”posted-on”>%s</span> ‘,
    $time_string
    );
    }, 10, 2 );

    #2396550
    David
    Staff
    Customer Support

    Did you read this article?

    https://docs.generatepress.com/article/adding-php/

    TLDR: Are you using a Child Theme?
    If Yes, then add the snippet to the Child Themes > functions.php
    If No, then use the Code Snippets plugin to add that snippet

    #2397048
    MD Tohidul

    How can I understand that I am using a Child Theme?

    #2397097
    Leo
    Staff
    Customer Support

    Go to Appearance > Themes and see if you are using a child theme there.

    I don’t believe so when looking at your replies so the Code Snippets plugin will be the best solution.

    #2400464
    MD Tohidul

    Still can fixed my issue? Can you help?

    #2400493
    MD Tohidul

    Code Snippets is not working with the previous mentioned php code. please tell me how can I fix my issue?

    #2400499
    Leo
    Staff
    Customer Support

    What exactly isn’t working when you add the code using Code Snippets?

    Any errors?

    Can you link us to the page in question and make sure all caching related plugins are disabled?

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