Ich habe die Kategorien neu geordnet und einen Beschreibungs Text hinzugefügt.
Nun werden bei der Auswahl einer Unterkategorie, plötzlich keine Artikel im Archiv angezeigt.
Nur wenn ich auf die Hauptkategorie gehe.
Woran liegt das.
Mfg Maffy
Um schreiben oder kommentieren zu können, benötigen Sie ein Benutzerkonto.
Sie haben schon ein Benutzerkonto? Melden Sie sich hier an.
Jetzt anmeldenHier können Sie ein neues Benutzerkonto erstellen.
Neues Benutzerkonto erstellenIch habe die Kategorien neu geordnet und einen Beschreibungs Text hinzugefügt.
Nun werden bei der Auswahl einer Unterkategorie, plötzlich keine Artikel im Archiv angezeigt.
Nur wenn ich auf die Hauptkategorie gehe.
Woran liegt das.
Mfg Maffy
Hallo,
ich suche Plug-Ins mit dem ich unter einem Artikel
eine Liste mit Einzelnachweisen für Literatur
eine Liste mit Siehe auch und Links zu Artikel
einbinden kann.
Offenbar bekommt man hier nur dann Hilfe wenn man was Bezahlt.
Nach langem suchen, habe ich es nun selber hinbekommen, dass er mir mein Veranstaltungen als Liste anzeigt.
Falls es jemand gebrauchen kann hier ist der Code:
##################################
// Shortcode Ausgabe
##################################
//Schort [events]
function get_events_shortcode($atts){
global $post;
// Das Datum von Heute
$today = date("Y-m-d");
// Events nach Datum Sortieren
$args1 = array(
"post_type" => 'events',
'meta_key' => 'event_date', // name of custom field Format
'orderby' => 'meta_value',
"order" => 'ASC',
"posts_per_page" => 5,
'meta_query' => array(
array(
'key' => 'event_date',
'value' => $today,
'compare' => '>=',
'type' => 'DATE',
)
),
);
$loop = new WP_Query( $args1 );
if( $loop->have_posts() ):
echo '<h1 class="entry-title"> <u> Aktuelle Wandertermine: </u></h1>';
echo '<p> Hier finden Sie meine aktuellen Wandertermine entlang der Fränkischen Saale.</p>';
while( $loop->have_posts() ): $loop->the_post();
//$titel = the_title( '<b><u>', '</u></b>' );
$my_title = get_the_title();
$my_content1 = get_post_meta( get_the_ID(), 'event_start_time', true );
$my_content2 = get_post_meta( get_the_ID(), 'event_end_time', true );
$my_content3 = get_post_meta( get_the_ID(), 'event_location', true );
$my_content4 = get_post_meta( get_the_ID(), 'event_start_time', true );
$my_eventdesc = get_post_meta( get_the_ID(), 'event_desc', true );
// Datumsformat ändern auf Deutsches Format
$custom_date = get_post_meta( get_the_ID(), 'event_date', true );
$my_eventdate = date('d.m.Y',strtotime($custom_date));
$heute = date('d.m.Y');
$titel_link = '<a href='.esc_url( get_permalink( get_the_ID() ) ).'>'.$my_title.'</a>';
// Daten anzeigen wenn diese nicht älter sind als heute
echo '<section class="event_container past">';
echo ''.$titel_link.'<br>';
echo '<em>'.$my_eventdesc.'</em><br>';
echo '<b>Wann:</b> '.$my_eventdate.' <b>Start:</b> '.$my_content1.' - <b>Rückkehr:</b> '.$my_content2.'<br>';
echo '<b>Treffpunkt:</b> '.$my_content3 .'<br> </p>';
echo '</section>';
endwhile;
endif;
wp_reset_query();
}
add_shortcode( 'events', 'get_events_shortcode' );
Alles anzeigen
Ich habe ein Custom Post Typ für Events erstellt.
Nun möchte ich die nächsten aktuellen Events anzeigen lassen.
Er zeigt mir alle Einträge an, die auch älter sind als heute.
Währe schön, wenn mir jemand Helfen kann.
// Veranstaltungen ausgeben mit Shortcode
function get_events_shortcode($atts){
global $post;
$today = date('d.m.Y', strtotime('-6 hours'));
// Events nach Datum Sortieren
$args1 = array(
"post_type" => 'events',
'meta_key' => 'event_date', // name of custom field Format
'orderby' => 'meta_value',
"order" => 'ASC',
"posts_per_page" => 5,
'meta_query' => array(
array(
'key' => 'event_date',
'value' => $today,
'compare' => '<=',
)
),
);
$loop = new WP_Query( $args1 );
if( $loop->have_posts() ):
echo '<h3> <u> Aktuelle Wandertermine: </u></h3>';
while( $loop->have_posts() ): $loop->the_post();
//$titel = the_title( '<b><u>', '</u></b>' );
$my_title = get_the_title();
$my_content1 = get_post_meta( get_the_ID(), 'event_start_time', true );
$my_content2 = get_post_meta( get_the_ID(), 'event_end_time', true );
$my_content3 = get_post_meta( get_the_ID(), 'event_location', true );
$my_content4 = get_post_meta( get_the_ID(), 'event_start_time', true );
$my_eventdesc = get_post_meta( get_the_ID(), 'event_desc', true );
// Datumsformat ändern auf Deutsches Format
$custom_date = get_post_meta( get_the_ID(), 'event_date', true );
$my_eventdate = date('d.m.Y',strtotime($custom_date));
$heute = date('d.m.Y');
$titel_link = '<a href='.esc_url( get_permalink( get_the_ID() ) ).'>'.$my_title.'</a>';
// Daten anzeigen wenn diese nicht älter sind als heute
echo '<section class="event_container past">';
echo ''.$titel_link.' <br><em>'.$my_eventdesc.'</em> '.$details_link.' <br> <b>Wann:</b> '.$my_eventdate.' ';
echo '<b>Treffpunkt:</b> '.$my_content3 .',<br> <b>Start:</b> '.$my_content1.' - <b>Rückkehr:</b> '.$my_content2.' </p>';
echo '</section>';
endwhile;
endif;
wp_reset_query();
}
add_shortcode( 'events', 'get_events_shortcode' );
// Daten speichern
add_action('save_post', 'save_event_details');
function save_event_details(){
global $post;
$date = get_post_meta( $post_id, 'event_date', true );
$time = '00:00:00';
$date = date( 'm/d/Y', $date );
$timestamp = strtotime( $date . ' ' . $time );
save_event_field('event_date', $timestamp );
save_event_field("event_start_time");
save_event_field("event_end_time");
save_event_field("event_location");
save_event_field("event_location_url");
save_event_field("event_desc");
}
function save_event_field($event_field) {
global $post;
if(isset($_POST[$event_field])) {
update_post_meta($post->ID, $event_field, $_POST[$event_field]);
}
}
Alles anzeigen
Da man hier im Forum leider keine Antworten erhält, muss man versuchen das selber hin zu bekommen.
Habe nun einen Code gefunden mit dem ich die Spaltenbreite anpassen kann.
//add a filter and an action to the events custom post type
add_filter('manage_edit-events_columns', 'events_edit_columns');
add_action('manage_posts_custom_column', 'events_custom_columns');
//edit events columns names
function events_edit_columns ($columns) {
$columns = array(
"cb" => "<input type=\"checkbox\" />",
"title" => "Event Name",
"location" => "Location",
"eventdate" => "Datum",
"start" => "Start + Ende",
"eventdate" => "Wann",
"author" => "Autor",
"date" => "Erstellt"
);
return $columns;
}
//edit content for all the added columns
//for the events custom post type
function events_custom_columns ($column) {
global $post;
switch($column)
{
case "location":
$custom = get_post_custom();
echo ' ' . $custom["event_desc"][0] .' <br>';
echo $custom["event_location"][0];
break;
case "eventdate":
//$custom = get_post_custom();
//echo $custom['event_date'][0];
$custom = get_post_custom();
$custom_date = $custom['event_date'][0];
$eventdate = date('d.m.Y',strtotime($custom_date));
echo '<em>'.$eventdate .'</em>';
break;
case "start":
$custom = get_post_custom();
echo '<em>'.$custom['event_start_time'][0].' - '.$custom['event_end_time'][0].'</em>';
break;
}
}
// Spaltenbreite anpassen
add_action('admin_head', 'hidey_admin_head');
function hidey_admin_head() {
echo '<style type="text/css">';
echo '.column-eventlocation { width:100px }';
echo '.column-eventdate { width:100px }';
echo '.column-start { width:100px }';
echo '.column-author { width:100px }';
echo '.column-title a { width:50% }';
echo '</style>';
}
Alles anzeigen
Ich habe das nun soweit hin bekommen das alle Daten angezeigt werden.
Wie kann ich noch die Spaltenbreiten anpassen und ändern?
Die ersten beiden Spalten sollen sich an den Text anpassen
//add a filter and an action to the events custom post type
add_filter('manage_edit-events_columns', 'events_edit_columns');
add_action('manage_posts_custom_column', 'events_custom_columns');
//edit events columns names
function events_edit_columns ($columns) {
$columns = array(
"cb" => "<input type=\"checkbox\" />",
"title" => "Event Name",
"location" => "Location",
"eventdate" => "Datum",
"start" => "Start + Ende",
"eventdate" => "Wann",
"author" => "Autor",
"date" => "Create"
);
return $columns;
}
//edit content for all the added columns
//for the events custom post type
function events_custom_columns ($column) {
global $post;
switch($column)
{
case "location":
$custom = get_post_custom();
echo ' ' . $custom["event_desc"][0] .' <br>';
echo $custom["event_location"][0];
break;
case "eventdate":
//$custom = get_post_custom();
//echo $custom['event_date'][0];
$custom = get_post_custom();
$custom_date = $custom['event_date'][0];
$eventdate = date('d.m.Y',strtotime($custom_date));
echo '<em>'.$eventdate .'</em>';
break;
case "start":
$custom = get_post_custom();
echo '<em>'.$custom['event_start_time'][0].' - '.$custom['event_end_time'][0].'</em>';
break;
}
}
Alles anzeigen
Ich habe das nun so geändert.
Nun zeigt er die location Daten an, aber bei dem Event Datum steht nicht das event_datum dort.
Es erscheint das Erstellungsdatum.
//add a filter and an action to the events custom post type
add_filter('manage_edit-events_columns', 'events_edit_columns');
add_action('manage_posts_custom_column', 'events_custom_columns');
//edit events columns names
function events_edit_columns ($columns) {
$columns = array(
"cb" => "<input type=\"checkbox\" />",
"title" => "Event Name",
"location" => "Location",
"eventdate" => "Wann",
"author" => "Autor",
"date" => "Create"
);
return $columns;
}
//edit content for all the added columns
//for the events custom post type
function events_custom_columns ($column) {
global $post;
switch($column)
{
case "location":
$custom = get_post_custom();
echo $custom["event_location"][0];
break;
case "eventdate":
$custom = get_post_custom();
echo $custom['event_date'][0];
break;
case "start":
$custom = get_post_custom();
echo $custom['event_start'][0];
break;
}
}
Alles anzeigen
Ich habe ein einfaches Event Verwaltung CPT erstellt.
Nun möchte ich auf der Startseite des Plug-In im Adminbereich eigene Spalten einfügen.
Die Spaltenüberschriften werden angezeigt aber die Inhalte für event_date und event_location sind leer.
// Benutzerdefinierte Spalten hinzufügen
add_filter("manage_edit-events_columns", "edit_event_columns" );
add_action("manage_posts_events_column", "custom_event_columns");
function edit_event_columns($event_columns){
$event_columns = array(
"cb" => "<input type ='checkbox' />",
"title" => "Event",
"event_date" => "Wann",
"event_location" => "Location"
);
return $event_columns;
}
function custom_event_columns($event_column){
global $post;
switch ($event_column)
{
case "event_date":
$event_date = get_post_meta($post->ID, 'event_date', true);
echo $event_date;
break;
case "event_location":
$event_location = get_post_meta($post->ID, 'event_location', true);
echo $event_location;
break;
}
}
Alles anzeigen
Inzwischen hat sich das erledig.
Da es leider kaum vernünftige Anfänger Tut gibt und nach Tage langem suchen und übersetzen habe ich es irgendwie hinbekommen.
Ich habe mir folgende einfach Eventverwaltung erstellt.
Wie lautet der Code, um das Datum im Deutschen Format abzuspeichern?
<?php
/*
Plugin Name: My Events
Description: Einfache Benutzerdefiniert Post Typen My Event anlegen und verwalten
Author: Matthias
Version: 0.0.1
Author URI: http://www.wandernimsaaletal.de
*/
/* Copyright 2014 Matthias Reichert
*/
add_action('init', 'event_register');
function event_register() {
$labels = array(
'name' => _x('Events', 'post type general name'),
'singular_name' => _x('Event', 'post type singular name'),
'add_new' => _x('Add New', 'event'),
'add_new_item' => __('Add New Event'),
'edit_item' => __('Edit Event'),
'new_item' => __('New Event'),
'view_item' => __('View Event'),
'search_items' => __('Search Events'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','editor','thumbnail',)
);
register_post_type( 'events' , $args );
}
// Spalten hinzufügen
add_action("manage_posts_custom_column", "events_custom_columns");
add_filter("manage_events_posts_columns", "events_edit_columns");
function events_edit_columns($columns){
$columns = array(
"cb" => "<input type=\"checkbox\" />",
"title" => "Event",
"event_date" => "Event Date",
"event_location" => "Location",
"event_city" => "City",
);
return $columns;
}
function events_custom_columns($column){
global $post;
$custom = get_post_custom();
switch ($column) {
case "event_date":
echo format_date($custom["event_date"][0]) . '<br /><em>' .
$custom["event_start_time"][0] . ' - ' .
$custom["event_end_time"][0] . '</em>';
break;
case "event_location":
echo $custom["event_location"][0];
break;
case "event_city":
echo $custom["event_city"][0];
break;
}
}
// Einträge sortieren
add_filter("manage_edit-events_sortable_columns", "event_date_column_register_sortable");
add_filter("request", "event_date_column_orderby" );
function event_date_column_register_sortable( $columns ) {
$columns['event_date'] = 'event_date';
return $columns;
}
function event_date_column_orderby( $vars ) {
if ( isset( $vars['orderby'] ) && 'event_date' == $vars['orderby'] ) {
$vars = array_merge( $vars, array(
'meta_key' => 'event_date',
'orderby' => 'meta_value_num'
) );
}
return $vars;
}
// Meta Box für die Details
add_action("admin_init", "events_admin_init");
function events_admin_init(){
add_meta_box("event_meta", "Event Details", "event_details_meta", "events", "normal", "default");
}
// Datunsformat
function get_default_date_format() {
return 'Y-m-d H:i:s';
}
function event_details_meta() {
//Das post-Objekt einlesen
global $post;
//Metadaten des Posts ermitteln (falls Event bearbeitet wird,
//sollen sofort die gespeicherten Werte angezeigt werden!)
echo '<div class="meta_box_work">';
echo'<label><span>An welchem Datum und zu welcher Zeit beginnt die Veranstaltung.</span></label>';
echo '<p><label><b>Datum:</b><label>';
echo '<input type="text" name="event_date" value="' . get_event_field("event_date") . '" /> <em> Format:YYYY.dd.mm</em> ';
// event_start_time
echo '</p><p><label>Start: </label><input type="text" name="event_start_time" value="' . get_event_field("event_start_time") . '" /><em>(hh:mm) oder (00:00)</em></p>';
// event_end_time
echo '<p><label>End Time: </label><input type="text" name="event_end_time" value="' . get_event_field("event_end_time") . '" /> <em>((hh:mm) oder (00:00))</em> </p>';
// event_location
echo '<p><label>Location: </label><input type="text" size="70" name="event_location" value="' . get_event_field("event_location") . '" /></p>';
// event_location_url
echo '<p><label>Location URL: </label><input type="text" size="70" name="event_location_url" value="' . get_event_field("event_location_url") . '" /></p>';
echo '</div>';
}
// Daten holen wenn vorhanden
function get_event_field($event_field) {
global $post;
$custom = get_post_custom($post->ID);
if (isset($custom[$event_field])) {
return $custom[$event_field][0];
}
}
// Daten speichern
add_action('save_post', 'save_event_details');
function save_event_details(){
global $post;
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
if ( get_post_type($post) == 'event')
return;
save_event_field("event_date");
save_event_field("event_start_time");
save_event_field("event_end_time");
save_event_field("event_location");
save_event_field("event_location_url");
}
function save_event_field($event_field) {
global $post;
if(isset($_POST[$event_field])) {
update_post_meta($post->ID, $event_field, $_POST[$event_field]);
}
}
// Shortcode Ausgabe
//[myevents]
function get_events_shortcode($atts){
global $post;
$args = array(
'post_type' => 'events', // enter your custom post type
'orderby' => 'menu_order',
'order' => 'ASC',
'posts_per_page'=> '2', // overrides posts per page in theme settings
'paged' => $paged, // Pagination page
);
$loop = new WP_Query( $args );
if( $loop->have_posts() ):
echo '<h3> <u> Aktuelle Wandertermine: </u></h3>';
while( $loop->have_posts() ): $loop->the_post();
//the_post();
$titel = the_title( '<b><u>', '</u></b>' );
$my_eventdate = get_post_meta( get_the_ID(), 'event_date', true );
$my_content1 = get_post_meta( get_the_ID(), 'event_start_time', true );
$my_content2 = get_post_meta( get_the_ID(), 'event_end_time', true );
$my_content3 = get_post_meta( get_the_ID(), 'event_location', true );
echo '<section class="event_container past">';
echo ''.$titel.' <br> <b>Wann:</b> '.$my_eventdate.' ';
echo '<b>Treffpunkt:</b> '.$my_content3 .',<br> <b>Start:</b> '.$my_content1.' - <b>Rückkehr:</b> '.$my_content2.' </p>';
echo '</section>';
endwhile;
endif;
wp_reset_query();
}
add_shortcode( 'events', 'get_events_shortcode' );
?>
Alles anzeigen
Ich habe ein kleines CPT erstellt um Bücher zu verwalten.
Wie kann ich nun eine Auswahlliste erstellen mit allen Wordpress Artikeln die ich geschrieben habe.
Wie kann ich diese Feld unter dem Textarea Feld anzeigen lassen.
Wie kann ich die Auswahl speichern und im Template ausgeben.
Ich habe die Funktionen nun soweit erweitert das er die Kategorien etc. anlegt und speichert.
Wenn ich im Suchen Feld ein Wort eintrage findet er die Bücher und Beiträge usw. .
Wenn ich auf einen Tag klicke findet er nichts.
Wenn ich eine Kategorie auswähle, die Anzahl der Einträge in der Kategorie passt,
werden die Bücher nicht angezeigt. Nur die Beiträge in dieser Kategorie.
Ich habe da nun schon einige Zeit gesucht aber ich bin noch nicht fündig geworden wie ich das hin bekomme.
add_action( 'init', 'create_post_type' );
function create_post_type() {
$labels = array(
'name' => _x('Books', 'post type general name'),
'singular_name' => _x('Book', 'post type singular name'),
'add_new' => _x('Add New', 'book'),
'add_new_item' => __('Add New Book'),
'edit_item' => __('Edit Book'),
'new_item' => __('New Book'),
'view_item' => __('View Book'),
'search_items' => __('Search Books'),
'not_found' => __('No books found'),
'not_found_in_trash' => __('No books found in Trash'),
'parent_item_colon' => '',
'menu_name' => 'Books'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => true,
'menu_position' => null,
'supports' => array('title','editor','author','thumbnail','excerpt','comments','customfields'),
'taxonomies' => array( 'category', 'post_tag' ), // add default post categories and tags
'public' => true,
'rewrite' => array('slug' => 'custom')
);
register_post_type( 'book', $args );
//flush_rewrite_rules();
register_taxonomy( 'book_category', // register custom taxonomy - quote category
'books',
array( 'hierarchical' => true,
'label' => __( 'book categories' )
)
);
register_post_type('book',$args);
}
// hook into the init action and call create_book_taxonomies when it fires
add_action( 'init', 'create_book_taxonomies', 0 );
// create two taxonomies, genres and writers for the post type "book"
function create_book_taxonomies() {
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
'name' => _x( 'Genres', 'taxonomy general name' ),
'singular_name' => _x( 'Genre', 'taxonomy singular name' ),
'search_items' => __( 'Search Genres' ),
'all_items' => __( 'All Genres' ),
'parent_item' => __( 'Parent Genre' ),
'parent_item_colon' => __( 'Parent Genre:' ),
'edit_item' => __( 'Edit Genre' ),
'update_item' => __( 'Update Genre' ),
'add_new_item' => __( 'Add New Genre' ),
'new_item_name' => __( 'New Genre Name' ),
'menu_name' => __( 'Genre' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'genre' ),
);
register_taxonomy( 'genre', array( 'book' ), $args );
// Add new taxonomy, NOT hierarchical (like tags)
$labels = array(
'name' => _x( 'Writers', 'taxonomy general name' ),
'singular_name' => _x( 'Writer', 'taxonomy singular name' ),
'search_items' => __( 'Search Writers' ),
'popular_items' => __( 'Popular Writers' ),
'all_items' => __( 'All Writers' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __( 'Edit Writer' ),
'update_item' => __( 'Update Writer' ),
'add_new_item' => __( 'Add New Writer' ),
'new_item_name' => __( 'New Writer Name' ),
'separate_items_with_commas' => __( 'Separate writers with commas' ),
'add_or_remove_items' => __( 'Add or remove writers' ),
'choose_from_most_used' => __( 'Choose from the most used writers' ),
'not_found' => __( 'No writers found.' ),
'menu_name' => __( 'Writers' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'writer' ),
'exclude_from_search' => true,
);
register_taxonomy( 'writer', 'book', $args );
}
//CREATE CUSTOM TAXONOMIES
// Suchen und finden
function add_custom_types_to_tax( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
// Get all your post types
$post_types = array( 'post', 'books', 'book_category' );
$query->set( 'post_type', $post_types );
return $query;
}
}
add_filter( 'pre_get_posts', 'add_custom_types_to_tax' );
Alles anzeigen
Ich habe mir ein Benutzerdefinierten Post Typ angelegt um Flash Magazine zu verwalten.
Beim Speichern eines neuen Buches unter Add New Book wird die Kategorie beim aktualisieren nicht gespeichert.
Bei der Suche erhalte ich kein ergebniss.
Was muss ich da noch einbauen?
In der functions.php des Themplates habe ich folgenden Code eingebunden.
add_action( 'init', 'create_post_type' );
function create_post_type() {
$labels = array(
'name' => _x('Books', 'post type general name'),
'singular_name' => _x('Book', 'post type singular name'),
'add_new' => _x('Add New', 'book'),
'add_new_item' => __('Add New Book'),
'edit_item' => __('Edit Book'),
'new_item' => __('New Book'),
'view_item' => __('View Book'),
'search_items' => __('Search Books'),
'not_found' => __('No books found'),
'not_found_in_trash' => __('No books found in Trash'),
'parent_item_colon' => '',
'menu_name' => 'Books'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','editor','author','thumbnail','excerpt','comments')
);
register_post_type('book',$args);
}
function add_console_taxonomies() {
register_taxonomy('console', 'book', array(
// Hierarchical taxonomy (like categories)
'hierarchical' => true,
// This array of options controls the labels displayed in the WordPress Admin UI
'labels' => array(
'name' => _x( 'Book Category', 'taxonomy general name' ),
'singular_name' => _x( 'Book-Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Book-Categories' ),
'all_items' => __( 'All Book-Categories' ),
'parent_item' => __( 'Parent Book-Category' ),
'parent_item_colon' => __( 'Parent Book-Category:' ),
'edit_item' => __( 'Edit Book-Category' ),
'update_item' => __( 'Update Book-Category' ),
'add_new_item' => __( 'Add New Book-Category' ),
'new_item_name' => __( 'New Book-Category Name' ),
'menu_name' => __( 'Review Categories' ),
),
// Control the slugs used for this taxonomy
'rewrite' => array(
'slug' => 'console', // This controls the base slug that will display before each term
'with_front' => false, // Don't display the category base before "/locations/"
'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/"
),
));
}
add_action( 'init', 'add_console_taxonomies', 0 );
Alles anzeigen
Was ist den hier im Forum los?
Bekommt man hier auch mal eine Antwort oder Hilfe auf eine Frage?
Ich habe mir ein kleines Bücher Verwaltungs Plug- In erstellt.
Auf dem Localhost funktioniert das Script wunderbar, im Web gibt es Probleme sobald ich das Plug In Aktiviere.
Das Abmelden funktioniert nicht mehr. Das Speichern in einem Beitrag reagiert nicht.
Kann sich das bitte mal jemand ansehen woran das liegt!
Ich habe es selber gefunden. Da muss noch global $wpdb; rein dann funktioniert es.
Für mein Plug-In habe ich folgenden Shortcode erstellt:
function listbooks_handler() {
//run function that actually does the work of the plugin
$bookoutput = listbooks_function();
//send back text to replace shortcode in post
return $bookoutput;
}
function listbooks_function() {
// Datensätze holen
$table_name = $wpdb->prefix . "mybooks";
print "<h1>Wanderführer Übersicht ...</h1>";
// Daten ausgeben
$listbookdata = $wpdb->get_results(
"
SELECT book_id, book_title
FROM $table_name
ORDER BY book_id ASC
"
);
print "<ul id=\"Navigation\">";
foreach ( $listbookdata as $listbooks )
{
$book_id = $listbooks->book_id;
$book_title = $listbooks->book_title;
print"<li><a href=\"book.htm\">{$book_title}</a></li>";
}
print "</ul>";
}
?>
Alles anzeigen
Ich erhalte aber eine Fehlermeldung bei der Abfrage der Datenbank:
Bekommt man hier auch mal eine Antwort, oder sind hier nur lauter Experten unterwegs die nur nach Rechtschreibfehlern suchen?
wenn ich die seite edit.php über den Link wp-admin/admin.php?page=edit&bookid=1 anzeigen will erhalte ich die Meldung:
Du hast nicht die erforderlichen Rechte, um auf diese Seite zuzugreifen.
Wie muss ich diese Seite einbinden?
Brauch dringend hilfe damit ich weiter komme.
Ich habe mir jetzt folgendes kleines Plugin erstellt.
Wie muss ich die Seite edit.php einbinden, damit diese im Adminbereich erscheint?
<?PHP
/*
Plugin Name: Wanderführer - Verwalten
Plugin URI:
Description: Dieses Plugin erstellt eine Übersicht der Wanderführer.
Author: Matthias Reichert
Version: 1.0
Author URI: http://www.wandernimsaaletal.de
*/
add_action('admin_menu', 'bookAddMenu');
function bookAddMenu() {
add_menu_page('Wanderführer Verwalten', 'Wanderführer', 10, __FILE__, 'start');
add_submenu_page(__FILE__, 'Erstellen', 'Erstellen', 10, 'erstellen', 'addnew');
add_submenu_page(__FILE__, 'Erstellen', 'Erstellen', 10, 'erstellen', 'addnew');
add_submenu_page(__FILE__, 'Help', 'Help', 10, 'help', 'help');
}
function addnew() {
echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>';
echo '<h2>Neuen Eintrag anlegen:</h2>';
echo '</div>';
// Formular zum anlegen
require_once(ABSPATH . 'wp-content/plugins/mybooks/addnew.php');
}
function create_mybooks()
{
// do NOT forget this global
global $wpdb;
$table_name = $wpdb->prefix . "mybooks";
// this if statement makes sure that the table doe not exist already
if($wpdb->get_var("show tables like ".$table_name."") != 'wp_mybooks')
{
// Alte Tabelle löschen
$sql1 = "DROP TABLE IF EXISTS ".$table_name."";
$wpdb->query($sql1);
// Tabelle installieren
$sql2 = "
CREATE TABLE $table_name(
book_id int auto_increment not null,
book_title varchar(175),
book_desc text,
book_ausgabe varchar(5),
book_jahr varchar(5),
book_post_url varchar(125),
book_anhang1 varchar(100),
book_anhang2 varchar(100),
book_images varchar(100),
PRIMARY KEY (`book_id`)
)";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql2);
// Beispieldaten installieren
$wpdb->insert($table_name , array(
'book_title' => "Von der Quelle nach Alsleben" ,
'book_desc' => "Lorem ipsum in nulla ligula donec mollis massa porttitor ullamcorper risus, eu platea fringilla habitasse suscipit pellentesque donec est habitant, vehicula tempor ultrices placerat sociosqu ultrices consectetur ullamcorper tincidunt. quisque tellus ante nostra euismod nec suspendisse sem, curabitur elit malesuada lacus viverra sagittis sit ornare, orci augue nullam adipiscing pulvinar libero.",
'book_post_url' => "14",
'book_ausgabe' => "1",
'book_jahr' => "2013",
'book_anhang1' => "../wp-content/uploads/flipbooks/Wandern_FSW_1",
'book_anhang2' => "../wp-content/uploads/pdf/FSW_Ausgabe_1",
'book_images' => "../wp-content/uploads/flipbooks/Wandern_FSW_1/files/shot.png"
));
$wpdb->insert($table_name , array(
'book_title' => "Test Ausgabe 2" ,
'book_desc' => "Lorem ipsum in nulla ligula donec mollis massa porttitor ullamcorper risus, eu platea fringilla habitasse suscipit pellentesque donec est habitant, vehicula tempor ultrices placerat sociosqu ultrices consectetur ullamcorper tincidunt. quisque tellus ante nostra euismod nec suspendisse sem, curabitur elit malesuada lacus viverra sagittis sit ornare, orci augue nullam adipiscing pulvinar libero.",
'book_post_url' => "14",
'book_ausgabe' => "2",
'book_jahr' => "2013",
'book_anhang1' => "../wp-content/uploads/flipbooks/Wandern_FSW_2",
'book_anhang2' => "../wp-content/uploads/pdf/FSW_Ausgabe_2",
'book_images' => "../wp-content/uploads/flipbooks/Wandern_FSW_2/files/shot.png"
));
}
}
// this hook will cause our creation function to run when the plugin is activated
register_activation_hook( __FILE__, 'create_mybooks' );
// Startseite anzeigen
function start() {
global $wpdb;
$table_name = $wpdb->prefix . "mybooks";
print "<div id=\"icon-themes\" class=\"icon32\"><br></div>";
print "<div class=\"wrap\">";
print "<h2>Wanderführer Verwalten:</h2> <br>";
if ( current_user_can( 'manage_options' ) ) {
/* A user with admin privileges */
print " <p> Hier finden Sie eine Übersicht der Wanderführer : </p> <br>";
print "<div class=\"tablenav top\">";
print "<form enctype=\"multipart/form-data\" method=\"POST\" action=\"?page=erstellen\" style=\"float:left; margin:5px 20px 0 0\">";
print "<input type=\"submit\" class=’button-primary’ name=\"addnew\" value=\"Add New\" />";
print "</form>";
print "</div>";
print "<table cellspacing=\"0\" class=\"wp-list-table widefat plugins\">";
print "<thead>";
print "<tr>";
print "<th style=\"\" class=\"manage-column\" id=\"name\" scope=\"col\">View:</th>";
print "<th style=\"\" class=\"manage-column\" id=\"name\" scope=\"col\">Ausgabe:</th>";
print "<th style=\"\" class=\"manage-column\" id=\"name\" scope=\"col\">Erstellt:</th>";
print "<th style=\"\" class=\"manage-column\" id=\"name\" scope=\"col\">Beschreibung:</th>";
print "<th style=\"\" class=\"manage-column\" id=\"name\" scope=\"col\">Aktionen:</th>";
print "</tr>";
print "</thead>";
print"<tfoot>";
print"<tr>";
print "<th style=\"\" class=\"manage-column\" id=\"name\" scope=\"col\"> </th>";
print "<th style=\"\" class=\"manage-column\" id=\"name\" scope=\"col\"> </th>";
print "<th style=\"\" class=\"manage-column\" id=\"name\" scope=\"col\"> </th>";
print "<th style=\"\" class=\"manage-column\" id=\"name\" scope=\"col\"> </th>";
print "<th style=\"\" class=\"manage-column\" id=\"name\" scope=\"col\"> </th>";
print "</tr>";
print "</tfoot>";
// Daten ausgeben
$booksdata = $wpdb->get_results(
"
SELECT book_id,book_title,book_desc,book_ausgabe,book_jahr,book_ausgabe,book_images,book_anhang1
FROM $table_name
ORDER BY book_id ASC
"
);
foreach ( $booksdata as $books )
{
$edit = "<a href=\"?page=edit&bookid=$books->book_id\">Edit</a>";
print"<tr>";
print "<td style=\"\" class=\"manage-column\" id=\"name\" scope=\"col\"><a href=\"".$books->book_anhang1."/index.html\" target=\"_blank\"><img src=\"".$books->book_images."\"></a></td>";
print "<td style=\"\" class=\"manage-column\" id=\"name\" scope=\"col\">Ausgabe ".$books->book_ausgabe."</td>";
print "<td style=\"\" class=\"manage-column\" id=\"name\" scope=\"col\">".$books->book_jahr."</td>";
print "<td style=\"\" class=\"manage-column\" id=\"name\" scope=\"col\"> ".$books->book_title." <br> ".$books->book_desc." </td>";
print "<td style=\"\" class=\"manage-column\" id=\"name\" scope=\"col\">".$edit." | Delete</td>";
print "</tr>";
}
print "</table>";
$book_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM ".$table_name.""));
echo '<p>Anzahl der Bücher: ' . $book_count . '</p>';
}
print "</div>";
}
// Startseite anzeigen
function help() {
print "<div id=\"icon-themes\" class=\"icon32\"><br></div>";
print "<h2>Wanderführer Verwalten</h2>";
if ( current_user_can( 'manage_options' ) ) {
/* A user with admin privileges */
print "<h3>Dokumentation:</h3>";
}
}
?>
Alles anzeigen