Erstellen eines Tabbed-Widget

Ich habe mein Widget eingerichtet, um Daten von benutzerdefinierten Post-Typen abzurufen. Ich verwende WP-Abfrage, um die Daten anzuzeigen, aber es zeigt immer noch nicht.

Ich habe auch die Datei in einem Sinn für eine einfachere Suche https://gist.github.com/609fc97c0352820eb762.git eingerichtet

Fußballvereine Filme Xbox Spiele Sermons Array (“Fußballclub”),);

//Custom query $tabbedquery = new WP_Query($args); ?> have_posts()) { while ($tabbedquery->have_posts()) { $tabbedquery->the_post(); ?> 

Movies
Xbox Games

Solutions Collecting From Web of "Erstellen eines Tabbed-Widget"

Finden Sie den Code, den Sie brauchen, um die js und css für Ihr Design hinzuzufügen

Es fügt drei benutzerdefinierte Posts hinzu und fügt Widgets zum Widget-Bereich hinzu, die Sie per Drag & Drop in jede Seitenleiste ziehen können.

 < ?php /** * Plugin Name: Custom Tabbed Plugin * Description: This is testing of the custom tabbed plugin * Version: 1.0.2 * Author: James Van Waza * Author URI: http://jamesvanwaza.com * License: GPL-2.0+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt */ /** * Registers a new post type * @uses $wp_post_types Inserts new post type object into the list * * @param string Post type key, must not exceed 20 characters * @param array|string See optional args description above. * @return object|WP_Error the registered post type object, or an error object */ add_action('init', 'aip_popup_init'); function add_custom_post_type(){ $labels = array( 'name' => __('Soccer Clubs', 'text-domain') , 'singular_name' => __('Soccer Club', 'text-domain') , 'add_new' => _x('Add New Soccer Club', 'text-domain', 'text-domain') , 'add_new_item' => __('Add New Soccer Club', 'text-domain') , 'edit_item' => __('Edit Soccer Club', 'text-domain') , 'new_item' => __('New Soccer Club', 'text-domain') , 'view_item' => __('View Soccer Club', 'text-domain') , 'search_items' => __('Search Soccer Clubs', 'text-domain') , 'not_found' => __('No Soccer Clubs found', 'text-domain') , 'not_found_in_trash' => __('No Soccer Clubs found in Trash', 'text-domain') , 'parent_item_colon' => __('Parent Soccer Club:', 'text-domain') , 'menu_name' => __('Soccer Clubs', 'text-domain') ); $args = array( 'labels' => $labels, 'hierarchical' => false, 'description' => 'description', 'taxonomies' => array() , 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_admin_bar' => true, 'menu_position' => null, 'menu_icon' => null, 'show_in_nav_menus' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'has_archive' => true, 'query_var' => true, 'can_export' => true, 'rewrite' => array( 'slug' => 'soccer-club' ) , 'capability_type' => 'post', 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'trackbacks', 'comments', 'revisions', 'page-attributes', 'post-formats' ) ); register_post_type('soccer-club', $args); $labels = array( 'name' => __('Movies', 'text-domain') , 'singular_name' => __('Movie', 'text-domain') , 'add_new' => _x('Add New Movie', 'text-domain', 'text-domain') , 'add_new_item' => __('Add New Movie', 'text-domain') , 'edit_item' => __('Edit Movie', 'text-domain') , 'new_item' => __('New Movie', 'text-domain') , 'view_item' => __('View Movie', 'text-domain') , 'search_items' => __('Search Movies', 'text-domain') , 'not_found' => __('No Movies found', 'text-domain') , 'not_found_in_trash' => __('No Movies found in Trash', 'text-domain') , 'parent_item_colon' => __('Parent Movie:', 'text-domain') , 'menu_name' => __('Movies', 'text-domain') ); $args = array( 'labels' => $labels, 'hierarchical' => false, 'description' => 'description', 'taxonomies' => array() , 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_admin_bar' => true, 'menu_position' => null, 'menu_icon' => null, 'show_in_nav_menus' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'has_archive' => true, 'query_var' => true, 'can_export' => true, 'rewrite' => array( 'slug' => 'movies' ) , 'capability_type' => 'post', 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'trackbacks', 'comments', 'revisions', 'page-attributes', 'post-formats' ) ); register_post_type('movies', $args); $labels = array( 'name' => __('Xbox Games', 'text-domain') , 'singular_name' => __('Xbox Game', 'text-domain') , 'add_new' => _x('Add New Xbox Game', 'text-domain', 'text-domain') , 'add_new_item' => __('Add New Xbox Game', 'text-domain') , 'edit_item' => __('Edit Xbox Game', 'text-domain') , 'new_item' => __('New Xbox Game', 'text-domain') , 'view_item' => __('View Xbox Game', 'text-domain') , 'search_items' => __('Search Xbox Games', 'text-domain') , 'not_found' => __('No Xbox Games found', 'text-domain') , 'not_found_in_trash' => __('No Xbox Games found in Trash', 'text-domain') , 'parent_item_colon' => __('Parent Xbox Game:', 'text-domain') , 'menu_name' => __('Xbox Games', 'text-domain') ); $args = array( 'labels' => $labels, 'hierarchical' => false, 'description' => 'description', 'taxonomies' => array() , 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_admin_bar' => true, 'menu_position' => null, 'menu_icon' => null, 'show_in_nav_menus' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'has_archive' => true, 'query_var' => true, 'can_export' => true, 'rewrite' => array( 'slug' => 'xbox-games' ) , 'capability_type' => 'post', 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'trackbacks', 'comments', 'revisions', 'page-attributes', 'post-formats' ) ); register_post_type('xbox-games', $args); } // creating a widget class f557TabberWidget extends WP_Widget { function __construct() { parent::__construct( 'f557TabberWidget', // Base ID __( 'Taber Title', 'text_domain' ), // Name array( 'description' => __( 'A Foo Widget', 'text_domain' ), ) // Args ); } function f557TabberWidget() { $widget_ops = array( 'classname' => 'f557TabberWidget', 'description' => 'Simple jQuery Tabber Widget' ); $this->WP_Widget( 'f557TabberWidget', 'f557Beginner Tabber Widget', $widget_ops ); } function widget($args, $instance) { ?> 
  • Soccer Clib
  • Movie
  • Xbox Games
< ?php $args = array( 'post_type' => 'soccer-club', 'posts_per_page' => 2 ); $soccer = new WP_Query($args); if( $soccer->have_posts() ) { while ($soccer->have_posts()) : $soccer->the_post(); ?>

< ?php the_title(); ?>

< ?php endwhile; } ?>
< ?php $args = array( 'post_type' => 'movies', 'posts_per_page' => 2 ); $soccer = new WP_Query($args); if( $soccer->have_posts() ) { while ($soccer->have_posts()) : $soccer->the_post(); ?>

< ?php the_title(); ?>

< ?php endwhile; } ?>
< ?php $args = array( 'post_type' => 'xbox-games', 'posts_per_page' => 2 ); $soccer = new WP_Query($args); if( $soccer->have_posts() ) { while ($soccer->have_posts()) : $soccer->the_post(); ?>

< ?php the_title(); ?>

< ?php endwhile; } ?>
< ?php } public function form( $instance ) { } public function update( $new_instance, $old_instance ) { } } add_action('widgets_init', function(){ register_widget( 'f557TabberWidget' ); }); ?>