Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1328343

    Changed the from topic: “Get published date instead of modified date on portfolio grid” into: “How to display date of publication in a portfolio grid”

    Hi everybody,

    I’m having troubles showing the correct date inside a portfolio grid. I found this piece of code somewhere on this forum:

    add_filter('avf_portfolio_extra', 'avf_portfolio_extra_mod', 10, 2);
    function avf_portfolio_extra_mod($output, $entry) {
    	$output = '<div class="portfolio-new-meta">';
    	$output .= "<time class='date-container minor-meta updated' $markup>".get_the_date( 'Y' )."</time>";
     	$output .= '</div>';
    	return $output;
    }

    As you can see here: Portfolio grid with year of publication
    the date is displayed, but it is the date of the page where I put the portfolio grid element for every entry but it is the modified date, not the published date When I look in the mysql database, I can see the column “post_date” – this one I need – and I see the column “post_modified” – this one I don’t want :)

    Is there a little snippet I can add to my functions.php that will provide me with the published date instead of modified date? I don’t mind if this changes will effect the whole site, I am not planning to use this modified date anywhere, it will be one big archive…

    Hope someone can help me out! Thanks from Utrecht / NL!

    Bas

    • This topic was modified 3 years, 1 month ago by Thisafternoon. Reason: I made a mistake in my question
    #1328457

    maybe I should rephrase my question a little bit…

    Where is the published date being replaced with the modified date for the portfolio items only and is there a way to revert this?

    For blog posts – using the blog post element in a grid for example, it does show the published date instead of the modified date. Why this difference for the Portfolio items?

    #1328459

    Ahw excuse me… the little snippet in functions.php is not working at all… it just displays the date of the page where the portfolio grid is begin used over and over again.

    It seems it has nothing at all to do with the modified date, my bad!

    Anyway. Is there a little snippet I can add to functions.php that will get the published date for all the portfolio items in the loop and add it to all the grid entries?

    #1328889

    Hi,
    Thank you for your patience and sorry for the very late reply, please try this snippet instead:

    add_filter('avf_portfolio_extra', 'avf_portfolio_extra_mod', 10, 2);
    function avf_portfolio_extra_mod($output, $entry) {
    	$output = '<div class="portfolio-new-meta">';
    	$output .= "<time class='date-container minor-meta updated' $markup>".get_the_modified_date( "Y-m-d", $entry )."</time>";
     	$output .= '</div>';
    	return $output;
    }
    

    in my test this seems to be working
    portfolio_modified_date_function_example.jpg

    Best regards,
    Mike

    #1329190

    Perfect Mike,

    Thank you so much! This is great for building an archive with Portfolio items.

    All the best,

    Bas

    #1329201

    Hi,
    Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘How to display date of publication in a portfolio grid’ is closed to new replies.