0

I'm not really a good web programmer but I wanted to try.

I want to make my result from database as a link for example I want "click here" as click would redirect to a new page or something. and I think the idea is like.. a href"this.webpage.com">click here /a my code is.

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>
            // I want this Job_Link_Info and Job_Link_Apply to be links naming Click for Details and Click to Apply respectively
            <td>{$row->Job_Link_Info}</td>
            <td>{$row->Job_Link_Apply}</td>
            </tr>";
    }

    $table .= "</table>";

    return $table . $content;
}
4

1 回答 1

0

假设 $row->Job_Link_Info 和 $row->Job_Link_Apply 是某种目的地,您只需添加一个 a 标签并将其用作 href 属性。

例如:

$table .= '<tr>
            <td>{' . $row->Job_Name . '}</td>
            <td>{' . $row->Job_Department . '}</td>
            // I want this Job_Link_Info and Job_Link_Apply to be links naming Click for Details and Click to Apply respectively
            <td><a href="{' . $row->Job_Link_Info . '}">Click for info</a></td>
            <td><a href="{' . $row->Job_Link_Apply . '}">Click to apply</a></td>
            </tr>';
于 2013-10-03T08:45:57.943 回答