Articles of widgets

List authors with posts in a category

I’m trying to create a custom widget to display contributing authors for the current category being viewed on a WordPress site. I have the following PHP code: <?php if (is_category()) { ?> // Grab posts from the current category <?php $current_category = single_cat_title(“”, false); $author_array = array(); $args = array( ‘numberposts’ => -1, ‘category_name’ => […]

Include chat (HTML, js, css) in all pages of WordPress

I need to add a chat widget in HTML, css and js, on all WP website. I tried the following in local (functions.php) and it worked fine but just on homepage. Same code online and nothing shows up. Any advice? Thank you in advance 🙂 <?php function add_chat ( ) { ?> <script type=”text/javascript”> SERVICE_PATTERN_CHAT_CONFIG […]

Is dynamic forms/entries possible in Widget?

I am new to WordPress Plugins development, and I just started working with the widget. My question is: What are the limitations of WordPress Widget? I tried to use jQuery to make the Widget Form more interactive/dynamic, but it doesn’t seem to work at all. For example, I have a button that when clicked will […]

How to create Blog Post Specific Widget

I want to create widgets which will display based on post. I have considered the option of creating a widget post type using Advanced custom post type plugin and populate this widget while writing post. What I want to understand is, is there any out of box functionality available which can be achieved easily. Or […]

How to determine the number of widgets contained in a sidebar via customizer JS

I am trying to access a widget area in the customizer via JS with the intent of getting count of the amount of widgets in the section. I am able to access some information with the code below but am not quite there. wp.customize.section( ‘sidebar-widgets-sidebar-1’, function( section ) { section ); });

Need help adding additional controls to a custom widget

public function widget($args, $instance) { extract( $args ); $title = apply_filters( ‘widget_title’, $instance[‘title’] ); /* Display the markup before the widget. */ echo $before_widget; if ( $title ) { echo $before_title . $title . $after_title; } /* Create a custom query and get the most recent 4 projects. */ $queryArgs = array( /* Do not […]

Shortcode displays always first. Once again

OK, I’ve had a problem with echoes in my last shortcodem, but everything works fine now. But I have another one: function myWidget_shortcode( $atts ) { extract( shortcode_atts( array( ‘title’ => ‘My Widget’, ‘value’ => ‘5’, ), $atts ) ); return the_widget(myWidget,’title=’.$title.’&value=’.$value); } add_shortcode(‘myWidget’, ‘myWidget_shortcode’); Can you tell me wy this shortcode always displays first […]

How/where is the global variable $wp_registered_widgets filled?

I have a problem of widgets not showing up, trying to investigate why $wp_registered_widgets is empty. Can somebody tell me where it gets filled from the database? How can I find out why the default widgets are not set.

Including PHP files doesn't work outside of Localhost

I have a bunch of widgets that I load from php files, like so: I added a PHP CODE widget and inside wrote: <?php include ‘/wp-content/themes/myTheme/parts/block1.php’; ?> This worked well on my localhost, but for some reason it stopped working when I uploaded that website online (and switched the home and site_url of course). Any […]

How can I use AJAX to save/update a widget form?

My custom widget’s form will have two pull-down menus: the content of the second menu is dependent on the user’s selection in the first menu (think of the way Country and State/Province works). I think the easiest implementation (though perhaps not the most user-friendly) would simply be to have the form automatically submit itself when […]