Home › Forums › WTI Like Post PRO › custom post type taxonomy
Tagged: custom post type, taxonomy, term
- This topic has 15 replies, 2 voices, and was last updated 5 years, 9 months ago by Webtechideas.
-
AuthorPosts
-
January 3, 2019 at 7:24 am #699ジョンジョンParticipant
Specify custom post type with widget.
I would like to specify a taxonomy or term.
Please tell me the code to write in functions.php.
January 3, 2019 at 7:26 am #700January 3, 2019 at 7:48 am #701ジョンジョンParticipantcheck
wti-like-post-site.php// Getting the most liked posts $query = "SELECT post_id, SUM(value) AS like_count, post_title, post_author FROM <code>{$wpdb->prefix}wti_like_post</code> L, {$wpdb->prefix}posts P "; $query .= "WHERE L.post_id = P.ID AND post_status = 'publish'"; // Get the posts for specific post type if(isset($args['post_type']) && !empty($args['post_type'])) { $post_type = trim($args['post_type']); $query .= " AND P.post_type IN ('" . str_replace(",", "','", $post_type) . "')"; }
I want to know the code to add a taxonomy input form with this widget.
January 3, 2019 at 8:36 am #702ジョンジョンParticipantfunction override_WtiMostLikedPostsWidget() { class WtiMostLikedPosts_Taxonomy extends WtiMostLikedPosts { private $taxonomy = 'category'; public function widget( $args, $instance ) { if ( !empty( $instance['taxonomy'] ) ) { $this->taxonomy = $instance['taxonomy']; }
January 3, 2019 at 8:37 am #703ジョンジョンParticipantadd_filter( 'widget_categories_dropdown_args', array( $this, 'add_taxonomy_dropdown_args' ), 10 ); add_filter( 'widget_categories_args', array( $this, 'add_taxonomy_dropdown_args' ), 10 ); parent::widget( $args, $instance ); }
January 3, 2019 at 8:38 am #704ジョンジョンParticipantpublic function form( $instance ) { parent::form( $instance ); $taxonomy = 'category'; if ( !empty( $instance['taxonomy'] ) ) { $taxonomy = $instance['taxonomy']; } $taxonomies = $this->get_taxonomies(); ?>
January 3, 2019 at 8:38 am #705ジョンジョンParticipant<p> <label for="<?php echo $this->get_field_id( 'taxonomy' ); ?>"><?php _e( 'Taxonomy:' ); ?></label><br /> <select id="<?php echo $this->get_field_id( 'taxonomy' ); ?>" name="<?php echo $this->get_field_name( 'taxonomy' ); ?>"> <?php foreach ( $taxonomies as $value ) : ?> <option value="<?php echo esc_attr( $value ); ?>"<?php selected( $taxonomy, $value ); ?>><?php echo esc_attr( $value ); ?></option> <?php endforeach; ?> </select> </p>
January 3, 2019 at 8:38 am #706ジョンジョンParticipant<?php } public function add_taxonomy_dropdown_args( $cat_args ) { $cat_args['taxonomy'] = $this->taxonomy; return $cat_args; } private function get_taxonomies() { $taxonomies = get_taxonomies( array( 'public' => true, ) ); return $taxonomies; } } unregister_widget( 'WtiMostLikedPosts' ); register_widget( 'WtiMostLikedPosts_Taxonomy' ); } add_action( 'widgets_init', 'override_WtiMostLikedPosts' );
January 3, 2019 at 8:39 am #707ジョンジョンParticipant
Add this way to functions.php, but what is wrong?January 3, 2019 at 5:33 pm #711WebtechideasKeymasterIt’s all broken here. Can you please share the details over email with whatever code you have written? Also, pass on the theme or plugin which you are using for the custom post type taxonomy.
January 4, 2019 at 12:32 am #712ジョンジョンParticipantwordpress@support.webtechideas.com
this mail??
January 4, 2019 at 12:56 am #713ジョンジョンParticipantWidget to expand.
class WtiRecentlyLikedPostsWidget extends WP_Widget
class WtiRecentlyLikedPostsWidget extends WP_Widget
I want expend widget to taxonomy term.
ex…..
◎post type → post
◎post type → custom post type◎category → category_name
× category → termI want to be able to acquire terms
————————————————–
php7
wordpress4.9
Custom Post Type UI
————————————————–how to
1 functions.php overwrite
if can not
2 wti-like-post-widgets.php editJanuary 4, 2019 at 9:22 am #714ジョンジョンParticipantIt is a very good plugin so please make it a widget that can be filtered by term.
January 5, 2019 at 8:58 am #717WebtechideasKeymasterEmail is support[at]webtechideas.com I think it will be a better approach to customize the existing widget to include taxonomy instead of creating a new one.
January 9, 2019 at 7:48 am #720ジョンジョンParticipantPlease tell me the code to add a term to the widget.
-
AuthorPosts
- The forum ‘WTI Like Post PRO’ is closed to new topics and replies.