我正在使用“ WP-Job Manager插件公司”在默认数据库配置中显示注册公司的公司列表,默认情况下会导致插件数据库。这是生成此类列表的插件脚本。
/**
* Build the shortcode.
*
* Not very flexible at the moment. Only can deal with english letters.
*
* @since WP Job Manager - Company Profiles 1.0
*
* @param array $atts
* @return string The shortcode HTML output
*/
public function build_company_archive( $atts ) {
global $wpdb;
$output = '';
$companies = $wpdb->get_col(
"SELECT pm.meta_value FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id
WHERE pm.meta_key = '_company_name'
AND p.post_status = 'publish'
AND p.post_type = 'wp_users'
GROUP BY pm.meta_value
ORDER BY pm.meta_value"
);
$_companies = array();
foreach ( $companies as $company ) {
$_companies[ strtoupper( $company[0] ) ][] = $company;
}
if ( $atts[ 'show_letters' ] ) {
$output .= '<div class="company-letters">';
foreach ( range( 'A', 'Z' ) as $letter ) {
$output .= '<a href="#' . $letter . '">' . $letter . '</a>';
}
$output .= '</div>';
}
$output .= '<ul class="companies-overview">';
foreach ( range( 'A', 'Z' ) as $letter ) {
if ( ! isset( $_companies[ $letter ] ) )
continue;
$output .= '<li class="company-group"><div id="' . $letter . '" class="company-letter">' . $letter . '</div>';
$output .= '<ul>';
foreach ( $_companies[ $letter ] as $company_name ) {
$count = count( get_posts( array( 'post_type' => 'job_listing', 'meta_key' => '_company_name', 'meta_value' => $company_name, 'nopaging' => true ) ) );
$output .= '<li class="company-name"><a href="' . $this->company_url( $company_name ) . '">' . esc_attr( $company_name ) . ' (' . $count . ')</a></li>';
}
$output .= '</ul>';
$output .= '</li>';
}
$output .= '</ul>';
return $output;
}
这里的事情是我在数据库中创建了所有用户:eldiades_wp-db»表:wp_users(主wordpress用户仪表板),我想在该列表中显示“ display_name”元键,因此所有在该列表中创建的用户表格将会显示。我认为这是一个语法错误,我错过了或者没有引起足够的重视,并且这导致我创建的用户没有显示在该列表中。
试图覆盖表和数据库名称,这是我尝试过的。
/**
* Build the shortcode.
*
* Not very flexible at the moment. Only can deal with english letters.
*
* @since WP Job Manager - Company Profiles 1.0
*
* @param array $atts
* @return string The shortcode HTML output
*/
public function build_company_archive( $atts ) {
global $wpdb;
$output = '';
$companies = $wpdb->get_col(
"SELECT pm.meta_value FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id
WHERE pm.meta_key = 'display_name'
AND p.post_status = 'publish'
AND p.post_type = 'wp_users'
GROUP BY pm.meta_value
ORDER BY pm.meta_value"
);
$_companies = array();
foreach ( $companies as $company ) {
$_companies[ strtoupper( $company[0] ) ][] = $company;
}
if ( $atts[ 'show_letters' ] ) {
$output .= '<div class="company-letters">';
foreach ( range( 'A', 'Z' ) as $letter ) {
$output .= '<a href="#' . $letter . '">' . $letter . '</a>';
}
$output .= '</div>';
}
$output .= '<ul class="companies-overview">';
foreach ( range( 'A', 'Z' ) as $letter ) {
if ( ! isset( $_companies[ $letter ] ) )
continue;
$output .= '<li class="company-group"><div id="' . $letter . '" class="company-letter">' . $letter . '</div>';
$output .= '<ul>';
foreach ( $_companies[ $letter ] as $company_name ) {
$count = count( get_posts( array( 'post_type' => 'job_listing', 'meta_key' => 'display_name', 'meta_value' => $company_name, 'nopaging' => true ) ) );
$output .= '<li class="company-name"><a href="' . $this->company_url( $company_name ) . '">' . esc_attr( $company_name ) . ' (' . $count . ')</a></li>';
}
$output .= '</ul>';
$output .= '</li>';
}
$output .= '</ul>';
return $output;
}
但是我认为这是一个语法错误,我丢失或没有引起足够的重视,这导致我创建的用户未显示在该列表中。
预期结果-显示我在数据库中创建的所有用户:eldiades_wp-db»表:wp_users
实际结果-“ display_name”或“ username”未显示我的用户列表。
也许我的语法是错误的,对此我需要一些咨询。
这是我的版面网址,以防您需要更多帮助