如何获得WP Job Manager的标题?

时间:2018-01-22 07:31:40

标签: php wordpress

我想创建一个在WP Job Manager中创建的最新作业的列表。但我不知道如何在WP Job Manager中调用作业标题(类或函数)。

以下是我的Hirings Post的代码。但目前显示的是wordpress post title。

<ul id="hiring-title">
  <span class="line"></span>
  <h4>HIRINGS</h4>

<!-- // Define our WP Query Parameters -->
<?php $the_query = new WP_Query( 'posts_per_page=4' ); ?>
					
<!-- // Start our WP Query -->
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
					
<!-- // Display the Post Title with Hyperlink -->
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
					
<!-- // Repeat the process and reset once it hits the limit -->
<?php 
  endwhile;
   wp_reset_postdata();
?>
</ul>

1 个答案:

答案 0 :(得分:1)

试试这个:

<ul id="hiring-title">
    <span class="line"></span>
    <h4>HIRINGS</h4>

    <?php
    // Get jobs
    $jobs = get_job_listings();

    // Jobs found, list them
    if ( $jobs->have_posts() ) {

        while ( $jobs->have_posts() ) : $jobs->the_post();
        ?>
        <li><a href="<?php the_job_permalink() ?>"><?php wpjm_the_job_title(); ?></a></li>
        <?php
        endwhile;

    } // No jobs available / found
    else {
        ?>
        <li>No jobs available.</li>
        <?php
    }

    // Restore original post object
    wp_reset_postdata();
    ?>
</ul>

有关详细信息,请查看WP Job Manager's documentation