Home › Forums › Welcome! › Pre-Sales Questions › Theming listview to match category
- This topic has 1 reply, 1 voice, and was last updated 10 years ago by
George.
-
AuthorPosts
-
May 9, 2016 at 2:14 am #1112124
Svend
GuestHi Brook,
I have implemented your code in our custom widget code. However, it does not provide the information I needed.
I have created a category under Events and an identical category under Post. Then I run a code where I get the Post category; however no matter what category reference (e.g, “Adobe Connect” or “adobe-connect”) I use I do not get the result needed. Is there something I am missing in order to make the do_shortcode working?
<CODE> // WIDGET: Display related courses class displayrelatedcourses extends WP_Widget { function __construct() { parent::__construct( // Base ID of your widget 'displayrelatedcourses', // Widget name will appear in UI __('Widget - Display Related Courses', 'wpb_widget_domain'), // Widget description array( 'description' => __( 'Custom widget displaying related courses', 'wpb_widget_domain' ), ) ); } // Creating widget front-end public function widget( $args, $instance ) { // ****** TITLE OF WIDGET ****** $title = apply_filters( 'widget_title', $instance['title'] ); // before and after widget arguments are defined by themes echo $args['before_widget']; if ( ! empty( $title ) ) echo $args['before_title'] . $title . $args['after_title']; // ****** CONTENT ****** $cat_difficulty = array(); foreach((get_the_category()) as $childcat) { // Post category ID for 'Events' equals 54 if (cat_is_ancestor_of(54, $childcat)) { do_shortcode('[tribe_events_list category="'.$childcat->cat_name.'"]'); } } echo $args['after_widget']; } } // WIDGET END // Register and load the widget function wpb_load_widget() { register_widget( 'displayrelatedcourses' ); } add_action( 'widgets_init', 'wpb_load_widget' ); </CODE>Regards,
Svend Tveden-Nyborg
May 9, 2016 at 2:35 am #1112133George
ParticipantHi,
Thanks for reaching out. The features you are trying to implement are possible, but would unfortunately require many code customizations to implement 🙁
To implement the features you describe, you would have to write that custom code or hire a professional developer to do it for you. We have a list of great developers here → http://m.tri.be/18k1 (and have no affiliation with any of these folks—they’re simply some well-respected names in the community that we’ve compiled to share in situations like this one).
We cannot help with code customizing, so I will close this thread for now.
Best of luck with your custom development.
Sincerely,
George -
AuthorPosts
- The topic ‘Theming listview to match category’ is closed to new replies.
