How to get individual values from custom widget?

I think you’re doing this the hard way. I would first visit phpMyAdmin, find your WP database, find the Options table, and then search the option_name field for the name of your widget using the %search_term% form. When you find it you’ll see all the data behind the widget stored in a single field/string called … 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

accessing wordpress serialized data outside wp

Use PHP’s unserialize function: <?php $data=”a:2:{i:0;s:12:”Sample array”;i:1;a:2:{i:0;s:5:”Apple”;i:1;s:6:”Orange”;}}”; $unserialized = unserialize($data); echo ‘<pre>’; print_r($unserialized); echo ‘</pre>’; ?> Result: Array ( [0] => Sample array [1] => Array ( [0] => Apple [1] => Orange ) ) Got the sample data over at unserialize.com, a handy little site if you want to quickly check what’s inside that … Read more

How to add WordPress Settings in sidebar widgets

The Text Widget does not parse PHP – it even strips it. You either could use a widget that is capable of parsing/interpreting PHP, such as the PHP Code Widget, or you could develop your own widget. Here is a very simple example of how this could look like: class WPDev172911TitleWidget extends WP_Widget { public … Read more

Input with pattern not working

Most likely because widgets are saved via AJAX, and, as far as I’m aware, the submit handler will bypass any HTML5 input rules unless they are explicitly checked with JavaScript. Your best bet is to validate/sanitize the data server-side, and pass back any messages if there is an input error. Chrome adding =”” is just … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)