• Resolved Gregorius

    (@gregoriusrs)


    Hi

    I want to change the post datePublished to my custom date.

    Can you help me with this?

    Getting the date is working fine, i’m using it somewhere else but maybe the filter is wrong?

    <code>
    
    add_filter( 'og_article_published_time_meta', 'my_article_published_time_meta' );
    function my_article_published_time_meta($datePublished)
    {
    if (in_category(array(344, 346))) {
    $event_date = get_field("event_data");
    $event_date_date = date('Y-m-d', strtotime($event_date));
    $datePublished = '<meta itemprop="datePublished" content="'. $event_date_date .'" />';
    return $datePublished;
    }
    return $datePublished;
    }
    
    
    }</code>
Viewing 1 replies (of 1 total)
  • Plugin Author Marcin Pietrzak

    (@iworks)

    hi @gregoriusrs

    Instead “meta” I suggest using “value” filters:

    <?php
    
    /**
     * <meta property="article:published_time" content="foo" />
     */
    add_filter( 'og_article_published_time_value', 'my_article_published_time_meta' );
    
    /**
     * <meta itemprop="datePublished" content="foo" />
     */
    add_filter( 'og_datePublished_value', 'my_article_published_time_meta' );
    
    function my_article_published_time_meta($datePublished) {
        return 'foo'; // your code here
    }
    

    Marcin

Viewing 1 replies (of 1 total)
  • The topic ‘Help with itemprop=”datePublished”’ is closed to new replies.