滤器the_content
并检查是否is_page( \'jobs\' )
是TRUE
:
add_filter( \'the_content\', \'get_scrapy_scraped\' );
function get_scrapy_scraped( $content )
{
global $wpdb;
if ( ! is_page( \'jobs\' ) )
return $content;
$table_name = $wpdb->prefix . "Careers";
$retrieve_data = $wpdb->get_results( "SELECT * FROM $table_name" );
if ( ! $retrieve_data )
return $content;
$table = \'<table><tr>
<th>Job Name</th>
<th>Location/Dept</th>
<th>Complete Info</th>
<th>Application Link<th>
</tr>\';
foreach ( $retrieve_data as $row )
{
$table .= "<tr>
<td>{$row->Job_Name}</td>
<td>{$row->Job_Department}</td>
<td>{$row->Job_Link_Info}</td>
<td>{$row->Job_Link_Apply}</td>
</tr>";
}
$table .= "</table>";
return $table . $content;
}