How to add a text widget during theme activation

You’re almost there, except each widget’s settings are stored separately from the sidebars_widgets option, which just stores widget “instances”. Try out the following function – you’ll still need to use register_sidebar, but it eases the pain for then pre-registering widgets on those sidebars. What it also does is ensure that any existing widgets & their … Read more

How to have Multiple Archives Widgets, one archive widget per category (in a different page)?

I finally found an answer using WordPress rewrites. The whole code is at the end and can be pasted in functions.php. There is just one parameter that you have to change $rules = cpt_generate_date_archives(‘news’, $wp_rewrite); news is the name of the post_type. So I added a second line to show how to have two archives. … Read more

display most popular tags in two columns

In my opinion you are doing it so complicated. I would rather do a classic query and then through css it made into 2-column. function top_tags() { $tags = get_the_tags(); if($tags) { $output=”<h4>Top tags</h4> <ul class=”top_tags”>”; foreach($tags as $tag) $output .= ‘<li><a href=”‘.get_tag_link($tag->term_id).'” title=”‘.$tag->name.'”>’.$tag->name.'</a></li>’; $output .= ‘</ul>’; echo $output; } } and your css .top_tags … Read more

How can I retrieve data within my widget

Read: SELECT_a_Column $sql = “SELECT ‘liters’ FROM ” . $wpdb->prefix . “tfp”; $liters = $wpdb->get_col( $sql ); if( $liters ) { foreach( $liters as $liter ) { echo ‘<option value=”‘ . $liter . ‘”>’ . $liter . ‘</option>’; } }