最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

filters - WordPress add_filter to post_date

programmeradmin2浏览0评论

I using a plugin that it makes posts and etc date to Persian Date but the problem is I just want to convert date in front not admin panel or etc. I found that part make this action:

add_filter('date_i18n', 'ztjalali_ch_date_i18n', 111, 4);

It using add_filter to do this on date_i18n function, can I change it somehow that convert only date in blog post in front. I'm not a wordpress expert and don't know too much about date_i18n, but I think it refer to all post date in everywhere, so can I change the code to only convert in front?

something like:

add_filter('post_date', 'ztjalali_ch_date_i18n', 111, 4);

I tried above but no success.

I using a plugin that it makes posts and etc date to Persian Date but the problem is I just want to convert date in front not admin panel or etc. I found that part make this action:

add_filter('date_i18n', 'ztjalali_ch_date_i18n', 111, 4);

It using add_filter to do this on date_i18n function, can I change it somehow that convert only date in blog post in front. I'm not a wordpress expert and don't know too much about date_i18n, but I think it refer to all post date in everywhere, so can I change the code to only convert in front?

something like:

add_filter('post_date', 'ztjalali_ch_date_i18n', 111, 4);

I tried above but no success.

Share Improve this question asked Oct 28, 2019 at 11:14 Jack The BakerJack The Baker 1012 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You need to add an additional filter on the frontend. Very basically it would look like this:

Frontend (eg. single.php):

echo apply_filters( 'my_custom_persian_filter', $post_date );

Backend (eg. functions.php)

function persian_date_function( $date ) {
    $date = $converted_to_persian; // there you convert date to persian
    return $date;
}
add_filter( 'my_custom_persian_filter', 'persian_date_function' );
发布评论

评论列表(0)

  1. 暂无评论