in_widget_form detect sidebar id

The relation between sidebars and widgets is stored in the sidebars_widgets option, as a serialized array that might look like this (expanded): Array ( [orphaned_widgets_1] => Array ( [0] => recent-posts-2 ) [wp_inactive_widgets] => Array ( [0] => calendar-2 ) [sidebar-1] => Array ( [0] => recent-posts-5 [1] => text-6 [2] => text-2 [3] => … Read more

Inserting Read More Tag in Widget

It’s pretty easy. Usually your widget is supposed to be held on sidebar.php In sidebar.php you may have been call the function the_content() to extract ‘About Me’ text. In stead of calling the_content() you need to call your own created function [suppose, read_more()] which should be defined in functions.php like this way: function read_more($limit){ $post_content … Read more

Turn off “This is the Primary Sidebar Widget Area” message

This code handles the sidebar: add_action( ‘genesis_sidebar’, ‘genesis_do_sidebar’ ); /** * Echo primary sidebar default content. * * Only shows if sidebar is empty, and current user has the ability to edit theme options (manage widgets). * * @since 1.2.0 */ function genesis_do_sidebar() { if ( ! dynamic_sidebar( ‘sidebar’ ) && current_user_can( ‘edit_theme_options’ ) ) … Read more

how to set a WP Plugin’s url

This is a perfect use case for WordPress’ REST API. It probably makes sense, to create a custom endpoint, where you can in detail define what results you need. Something along the lines of <?php add_action( ‘rest_api_init’, function () { register_rest_route( ‘kostas_calendar/v1’, ‘/feed/’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘kostas_calendar_endpoint_feed’, ) ); } ); function … Read more

Widget back end radio button issue

You got that problem because the radio buttons have different name; i.e. the_style_1 and the_style_2. So I’d suggest you to use the_style as the name for both the radio buttons: <p> <input class=”radio” type=”radio” <?php checked( $instance[ ‘the_style’ ], ‘style_1’ ); ?> id=”<?php echo $this->get_field_id( ‘the_style_1’ ); ?>” name=”<?php echo $this->get_field_name( ‘the_style’ ); ?>” value=”style_1″ … Read more

Displaying a WordPress widget by name

You would use the_widget https://codex.wordpress.org/Function_Reference/the_widget This template tag displays an arbitrary widget outside of a sidebar. It can be used anywhere in templates. <?php the_widget( $widget, $instance, $args ); ?> e.g. <?php the_widget( ‘WP_Widget_Archives’ ); ?>

Is it bad to add html to a widget by closing and reopening the php tags?

“Practice” is a matter of personal preference. The opening and closing PHP tags (<?php and ?>) are there as a matter of convenience. Basically, try to write your code in context. In example, // PHP code here ?><a href=”https://wordpress.stackexchange.com/questions/368897/<?php the_permalink() ?>”><?php the_title() ?></a><?php // PHP code here looks (to me) like HTML code plopped right … Read more