Site logo

[Resolved] the date is being duplicated on my blog posts

Home Forums Support [Resolved] the date is being duplicated on my blog posts

Home Forums Support the date is being duplicated on my blog posts

Viewing 15 posts - 1 through 15 (of 39 total)
  • Author
    Posts
  • #1805352
    Rob

    I’m using 2 GP elements (‘Last Updated’ and ‘Breadcrumbs’) and they seem to be in conflict with each other, as the same date is appearing twice at the top of all my blog posts (e.g. https://robpowellbizblog.com/top-10-lead-capture-tools/). The second date should be the date of first publication.

    Can you help with this?

    Many thanks!

    #1805462
    Elvin
    Staff
    Customer Support

    Hi Rob,

    The entry meta date shouldn’t display the modified date unless filtered.

    Can you share the snippets used in this?

    #1805515
    Rob

    Here is th code:

    strong.breadcrumb_last {
    display: none;
    }

    .entry-header {
    display: flex;
    flex-direction: column-reverse;
    }

    .single .updated-date-label {
    font-size: 16px;
    }

    .single .modified-date {
    font-size: 16px;
    }

    Thanks.

    #1805728
    David
    Staff
    Customer Support

    Hi there,

    did you use a Hook Element or a PHP Function to add the dates ?

    #1805762
    Rob

    for the breadcrumb snippet, I used the hook: generate_before_entry_title

    for the ‘date modified for blog posts’ I have the hook: ‘generate_before_content’ plus the following code:

    <span class=”updated-date-label”>Last Updated: </span><span class=”modified-date”><?php echo get_the_modified_date(‘F j, Y’); ?></span>

    #1805850
    David
    Staff
    Customer Support

    Do you have any functions anywhere eg. in Code Snippets or Child Theme ?

    #1808089
    Rob

    No, I don’t think so. I just followed the instructions from you guys at GP on how to add ‘last updated’ to my articles.

    #1808098
    Elvin
    Staff
    Customer Support

    Hi Rob,

    I did a bit of history backreading from previous topics you’ve open and I believe that duplicate you see is hooked in by an element on the screenshot on one of your replies (this one – https://generatepress.com/forums/topic/display-last-updated-date-on-blog-posts/#post-1619382)

    Assuming the label is actually what it does, I believe it’s “Date Modified for blog posts” Hook element. It matches the hook. The duplicate shows on generate_before_content hook. And what it shows matches the label.

    You can try removing that and see if the duplicate gets removed.

    #1808113
    Rob

    I deleted that ‘last Modified’ hook. I’m now attempting to put it back in (so as to follow up on your suggestion) but I’m getting an error message that “the element needs a location with the display rules”. Can you help?

    Thanks.

    #1808114
    Rob

    error message

    #1808122
    Rob

    So I have now resolved the above problem and have set a location for the rule to display:

    Last Modified Date

    #1808123
    Rob

    However, I now have no ‘Last Updated Info’ above my blog posts:

    Last Updated Info

    #1808127
    Rob

    Can you help with this?

    Thanks.

    #1808149
    Elvin
    Staff
    Customer Support

    To make things clearer:

    If an HTML element appears on the front-end, it’s usually added by the theme, or a plugin, or hooked in by either manually writing an add_action('hook_name_here',function(){...}) code or by using equivalent to it like hooking things in using Block or Hook Element.

    Doing a deeper dive to your site’s DOM structure, the duplicate appears where the generate_before_content hook is located – https://github.com/tomusborne/generatepress/blob/b60b853630da6d9015722da903e53c8064148b0a/content-single.php#L23

    With this, we have a clue as to what it is. This means, there’s likely something hooking into the mentioned hook. We just need to figure out which one. (manually coded, Hook element or Block element).

    Now the normal causes of this is when users hook in something using a Hook element or a Block element. More advanced users do this by manually writing the code on a functions.php or a code snippet. The more daring uses use a child theme template or modify the actual parent theme file. And they eventually forget how it’s added, hence the confusion.

    Now in your case, I’m not exactly sure which one you want to remove.

    If it’s the 1st one, with the label “Last Updated:” label, that one is added manually by hook. You remove it by simply deleting the add_action() code or the hook element you’ve inserted it through.

    If it’s the 2nd one, right before the “by author”, that one is the default date meta generated by the theme which we can easily hide by using CSS, or completely remove from render by unchecking “Display post date” on Appearance > Customize > Layout > Blog for Posts tab.

    #1808158
    Elvin
    Staff
    Customer Support

    However, I now have no ‘Last Updated Info’ above my blog posts:

    We can simply add it in using CSS:

    Example:

    .posted-on time.entry-date.updated-date:before {
        content: "Last Updated: ";
    }
Viewing 15 posts - 1 through 15 (of 39 total)
  • You must be logged in to reply to this topic.