You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为WP Job Manager添加仅显示7天内新发布职位的new标签

Hey there! Let's get that eye-catching "NEW" label added to your job listings that are less than 7 days old. I'll walk you through modifying your template code and adding some quick CSS to match your example.

Step 1: Modify Your Job Listing Template

First, open up your content-job_listing.php file (the one you shared) and find the section where the job title is displayed. That's this line:

<h3><?php wpjm_the_job_title(); ?></h3>

We'll add a check to see if the job was posted within the last 7 days, and display the label if so. Update that section to look like this:

<h3>
    <?php wpjm_the_job_title(); ?>
    <?php
    // Calculate days since job was posted
    $post_timestamp = get_post_time('U', true, $post);
    $current_timestamp = current_time('U');
    $days_since_posted = floor(($current_timestamp - $post_timestamp) / (60 * 60 * 24));
    
    // Show "NEW" label if posted within last 7 days
    if ($days_since_posted <= 7) {
        echo '<span class="new-job-label">NEW</span>';
    }
    ?>
</h3>

Step 2: Add CSS to Style the Label

Next, add this CSS to your theme's custom CSS section (Appearance > Customize > Additional CSS) to make the label look polished, matching your example screenshot:

.new-job-label {
    background-color: #00b894; /* Adjust this color to fit your theme */
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 3px;
    margin-left: 10px;
    vertical-align: middle;
}

Step 3: Test It Out

Save your changes, then check your job listings. Any position posted in the last 7 days should now show the "NEW" label right next to the job title. You can tweak the CSS colors, padding, or position to get it exactly how you want it.

A quick note: Since you're using a template override, make sure to keep a backup of this file if you update your theme later, so your changes don't get overwritten.

内容的提问来源于stack exchange,提问作者user9845001

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 06:42:53