请找到代码,你只需要为你的设计添加js和css
它将添加三个自定义贴子,并将小部件添加到小部件区域,您可以将其拖放到任何侧栏中。
<?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) {
?>
<div class="small-12 columns">
<ul class="tabs show-for-medium-up" data-tab>
<li>Soccer Clib</li>
<li>Movie</li>
<li>Xbox Games</li>
</ul>
<div class="tab1">
<?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(); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
endwhile;
}
?>
</div>
<div class="tab2">
<?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(); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
endwhile;
}
?>
</div>
<div class="tab3">
<?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(); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
endwhile;
}
?>
</div>
</div>
<?php
}
public function form( $instance ) {
}
public function update( $new_instance, $old_instance ) {
}
}
add_action(\'widgets_init\', function(){
register_widget( \'f557TabberWidget\' );
});
?>