How can I re-register my blogs widgets?

There is no such thing as a wp_options database “file” to my knowledge. Are you referring to the wp_options table? Maybe you’re working with sql files or something in a way I’m not familiar with? If you wiped the database table, how did you go about replacing it with a clean one? And if this … Read more

How to add social buttons like facebook and twitter in the footer of a theme?

Camilia, this is super easy to do with existing plugins, which you can find here: http://wordpress.org/extend/plugins/search.php?q=social+media But if you’re keen to the coding yourself, and you have widgets in place, you could simply use the text widget that also allows for html and manually add your social media links something like: <a href=”http://twitter.com/YourUsername”>Twitter</a><a href=”http://facebook.com/YourPage”>Facebook</a> If … Read more

disable default widgets in Responsive theme

You have to change the sidebar.php. In there, the default Sidebar main-sidebar is called. If no Widgets are registered in this Sidebar, the fallback function shows a monthly Archive. You have got two possibilities: Register a Widget for the Main Sidebar Remove the Fallback Function from sidebar.php. In this case, it would look like this: … Read more

How to add a recent post function to a text widget I created for practice?

In the function widget( $args, $instance ), which generates the widget output, add the following code before the echo $after_widget; line: // The Query $the_query = new WP_Query( array( ‘post_type’ => ‘page’, ‘posts_per_page’ => ‘3’ ) ); // The Loop while ( $the_query->have_posts() ) : $the_query->the_post(); echo ‘<li>’ . get_the_title() . ‘</li>’; endwhile; Additional information … Read more

Stuck with sidebar registering

get_sidebar(‘dfth’) looks for a sidebar-dfth.php file in your template directory. If not found, it loads the default sidebar. To call the sidebar you registered in a template, use e.g. <?php if ( is_active_sidebar( ‘dfth’ ) ) : ?> <div class=”first dfth-widgets”> <?php dynamic_sidebar( ‘dfth’ ); ?> </div><!– .first –> <?php endif; ?>

Trouble accessing a multidimensional array to add classes to default WordPress widgets

The problem isn’t how you are accessing the array, as you put it. It is with the str_replace line. That generates bad markup. You are replacing class=” with your classes, so <aside id=”whatever” class=”abc”> becomes <aside id=”whatever” full-blocks”>. That is just wrong. Try: $params[0][‘before_widget’] = preg_replace(‘/class=”([^”]*)”https://wordpress.stackexchange.com/”, ‘class=”‘.$class.'”‘, $params[0][‘before_widget’]); That should give you valid markup. I … Read more

Accessing widget information

It seems that the index value goes incrementing and we add/remove instances of the widget. To make sure the correct data is grabbed, I can only think of checking inside the widget data itself through some control variable, something like: Array ( [2] => Array ( Accessing widget information => asian kung-fu generation Accessing widget … Read more

Add html after the first widget in a sidebar

Register separate sidebar for the first widget and add requred HTML between sidebars in template file(s). <?php dynamic_sidebar(‘First Widget Sidebar’); ?> <div class”content”>Here only once</div> <?php dynamic_sidebar(‘Other Widgets Sidebar’); ?>