Show widget differently depending on if it’s in the sidebar or footer
you can always get the thumbnail, but size it with CSS as Xavier mentioned.
you can always get the thumbnail, but size it with CSS as Xavier mentioned.
you could use custom post types to keep them separate. or check in_category in single.php and load additional templates: if( in_category(‘country1’) ) include (TEMPLATEPATH . ‘/single-country1.php’); elseif( in_category(‘country2’) ) include (TEMPLATEPATH . ‘/single-country2.php’);
No parent necessary: the difference between a not-working widget and a working widget was this: $text1 = apply_filters( ‘widget_text1’, $instance[‘text1’], $instance ); vs: $text1 = apply_filters( ‘widget_text1’, empty($instance[‘text1’]) ? ” : $instance[‘text1’], $instance, $this->id_base); I realized putting multiple Random Text widgets on the same page, their titles worked, but their text content did not. So … Read more
I think the problem is that you’re calling get_post() (note: singular) instead of get_posts() (note: plural). EDIT Other problems: The get_posts() function uses the category array key, rather than category_name. The category array key expects category ID, rather than category slug. You’re not wrapping your looped list items (<li>…</li>) properly (i.e. within <ul></ul> tags)
I think I understand what looking for. I’ve put together some code I’ve taken from parts of my themes to give you an example. For the functions.php: <?php add_action( ‘after_setup_theme’, ‘ideatree_init’ ); if ( ! function_exists( ‘ideatree_init’ ) ): function ideatree_init() { // REGISTER THE NAV MENUS (3 in this case) add_action( ‘init’, ‘register_my_menus’ ); … Read more
You can create your own sidebar if you want. add the following to your functions.php register_sidebar(array(‘name’=>’Sidebar ‘, ‘before_widget’ => ‘<div class=”widget”>’, ‘after_widget’ => ‘</div>’, ‘before_title’ => ‘<p>’, ‘after_title’ => ‘</p>’, )); and you can use this widget by using the following code <?php dynamic_sidebar(‘sidebar’)?> Hope this helps
If I get your question right, as you mention Tag in the title, but not in the Content – and also mention a random image but then it’s not a library image but a custom field value… So, the following code will grab 1 random custom post type that has a custom field value that’s … Read more
I would consider the following … Register a new sidebar: function your_new_widget() { register_sidebar( array( ‘name’ => __( ‘Single View Sidebar’, ‘your_textdomain’ ), ‘id’ => ‘sidebar-single’, ‘description’ => __( ‘This widget area is found only on the single post view.’, ‘your_textdomain’ ), ) ); } add_action( ‘widgets_init’, ‘your_new_widget’ ); Create a new sidebar template: /** … Read more
Try this function: function get_category_comments($category_id, $limit = 5) { global $wpdb; $sql = ” SELECT {$wpdb->comments}.comment_ID FROM {$wpdb->comments}, {$wpdb->posts}, {$wpdb->term_taxonomy}, {$wpdb->term_relationships} WHERE 1=1 AND {$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID AND {$wpdb->term_relationships}.object_id = {$wpdb->posts}.ID AND {$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->term_taxonomy}.term_taxonomy_id AND {$wpdb->comments}.comment_approved = ‘1’ AND {$wpdb->term_taxonomy}.term_id = ‘{$category_id}’ ORDER BY {$wpdb->comments}.comment_date DESC LIMIT 0, {$limit} “; $comments = array(); foreach … Read more
http://codex.wordpress.org/Function_Reference/get_sidebar <?php get_sidebar(‘other’); ?> for instance will call the template sidebar-other.php you would add the dynamic_sidebar() code in that sidebar-other.php template; see also http://codex.wordpress.org/Widgetizing_Themes