首页 > 解决方案 > WordPress帖子上传时间问题

问题描述

我在 wordpress 中做了一个分类作为名称(研究)。

当我上传任何研究报告时,它显示我发布上传时间有几个小时错误,就像我在上午 9 点上传帖子时显示的是上午 6 点。

为什么会发生这种情况,有人可以告诉我吗?

这是我的代码:

<?php   
$x=1;  $args = array( 'post_type' => 'research' , 'posts_per_page' => '-1', 'order' => 'DESC', 'orderby' => 'date',); $index_query = new WP_Query($args); 

while ($index_query->have_posts()) : $index_query->the_post(); ?>
    <div class="col-md-6">
        <div class="res-det">
            <div class="card">
                <div class="card-header">
                    <a href="<?php echo get_field('research'); ?> "><img src="<?php echo the_post_thumbnail_url(); ?>"></a>
                </div>
                <div class="card-body">
                    <a href="<?php echo get_field('research'); ?>"><h3><?php echo the_title(); ?></h3></a>
                    <span>Published <?php echo get_the_date('F j, Y'); ?> </span>
                    <p><?php echo the_content(); ?></p>
                </div>
            </div>
        </div>
     </div>
                        
     <?php endwhile; wp_reset_query(); ?>
                        
     </div>

在函数文件中:

add_action('init', 'research');

function research()
{

    $labels = array(
        'name' => _x('research', 'post type general name'),
        'singular_name' => _x('research', 'post type singular name'),
        'add_new' => _x('Add New', 'research'),
        'add_new_item' => __('Add New research'),
        'edit_item' => __('Edit research'),
        'new_item' => __('New research'),
        'view_item' => __('View research'),
        'search_items' => __('Search research'),
        'not_found' => __('Nothing found'),
        'not_found_in_trash' => __('Nothing found in Trash'),
        'parent_item_colon' => ''
    );
    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'menu_icon' => true,
        'rewrite' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array('title','thumbnail','editor')
    );
    register_post_type('research', $args);

}

add_action('init', 'research_category', 0);


function research_category()

{

    $labels = array(
        'name' => _x('Category', 'taxonomy general name'),
        'singular_name' => _x('Category', 'taxonomy singular name'),
        'search_items' => __('Search Category'),
        'all_items' => __('All Category'),
        'parent_item' => __('Parent Category'),
        'parent_item_colon' => __('Parent Category:'),
        'edit_item' => __('Edit Category'),
        'update_item' => __('Update  Category'),
        'add_new_item' => __('Add New Category'),
        'new_item_name' => __('New Category'),
        'menu_name' => __('Category'),
    );
    register_taxonomy('research_category', array('research'), array(
        'hierarchical' => true,
        'labels' => $labels,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array('slug' => 'research_category'),
    ));
}

标签: phpwordpress

解决方案


推荐阅读