Erstellen einer Dropdown- und Filtertaste für zwei benutzerdefinierte Taxonomien, die einem benutzerdefinierten Post-Typ zugewiesen sind
-
16-10-2019 - |
Frage
Ich verwende den folgenden Code, um das Dropdown-Menü und Filtertaste für zwei benutzerdefinierte Taxonomien zu erstellen, die einem benutzerdefinierten Beitragstyp mit dem Namen Page-Inhalt zugeordnet sind (Voller vorheriger Code hier):
function parse_query($query) {
global $pagenow;
$qv = &$query->query_vars;
if ($pagenow=='edit.php' &&
isset($qv['taxonomy']) && $qv['taxonomy']=='locations' &&
isset($qv['term']) && is_numeric($qv['term'])) {
$term = get_term_by('id',$qv['term'],'locations');
$qv['term'] = $term->slug;
}
if ($pagenow=='edit.php' &&
isset($qv['taxonomy']) && $qv['taxonomy']=='page_sections' &&
isset($qv['term']) && is_numeric($qv['term'])) {
$term = get_term_by('id',$qv['term'],'page_sections');
$qv['term'] = $term->slug;
}
}
// Add filter drop-down menu for the custom taxonomies
function restrict_manage_posts() {
global $typenow;
global $wp_query;
if ($typenow=='page_content') {
$taxonomy = 'locations';
$locations = get_taxonomy($taxonomy);
wp_dropdown_categories(array(
'show_option_all' => __("Show All {$locations->label}"),
'taxonomy' => $taxonomy,
'name' => $taxonomy,
'orderby' => 'name',
'selected' => $wp_query->query['term'],
'hierarchical' => true,
'depth' => 3,
'show_count' => true, // This will give a view
'hide_empty' => true, // This will give false positives, i.e. one's not empty related to the other terms. TODO: Fix that
));
}
if ($typenow=='page_content') {
$taxonomy = 'page_sections';
$page_sections = get_taxonomy($taxonomy);
wp_dropdown_categories(array(
'show_option_all' => __("Show All {$page_sections->label}"),
'taxonomy' => $taxonomy,
'name' => $taxonomy,
'orderby' => 'name',
'selected' => $wp_query->query['term'],
'hierarchical' => true,
'depth' => 3,
'show_count' => true, // This will give a view
'hide_empty' => true, // This will give false positives, i.e. one's not empty related to the other terms. TODO: Fix that
));
}
}
YourSite_PageContent::on_load();
}
Aber ich bekomme die folgende Warnung:
Parse error: syntax error, unexpected T_STRING,
expecting T_FUNCTION in /home/alex/www/wpac/wp-content/themes
/prominent/functions/custom-post-types.php on line 181
Dies ist Zeile 181: YourSite_PageContent::on_load();
Lösung
Sie fehlen eine Schließklammer im Finale, wenn auch Bedingung. ;))
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit wordpress.stackexchange