Custom Post Type posts not getting picked up in archive widgets
Custom Post Type posts not getting picked up in archive widgets
Custom Post Type posts not getting picked up in archive widgets
First, create the custom WordPress widget. This will query all the years that have at least one post for your custom post type “Meeting.” Save the following code in your theme’s functions.php file: class Meeting_Archive_Widget extends WP_Widget { public function __construct() { parent::__construct(‘meeting_archive’, ‘Meeting Archive’, array(‘description’ => ‘List Meetings by Year’)); } public function widget($args, … Read more
The first parameter to wp_enqueue_script()—in this case, dashboard—is the handle of the script. The handle can be pre-registered using wp_register_script(), and that’s where the script’s path will be set. dashboard isn’t one of the default scripts that WordPress registers, but it’s entirely possible some other entity has registered it. Looking at the example code that … Read more
Seems like the theme you use (nice_hotel?) uses an extremely outdated version of registering a widget (see here). As this seems to be a premium theme, you should probably contact the themes author, but as i couldn’t find an “active” version of this theme (if it is nice_hotel: themeforest theme shows “no longer available”), you’re … Read more
Actually Twenty Twenty Three theme supports full site editing and is a Gutenberg Block theme, so it doesn’t support classic widgets, to use the widget mentioned above you would have to convert it to Gutenberg Block. Thanks
Add page post type to your code (tested): add_filter( ‘dashboard_recent_posts_query_args’, function(array $queryArgs) { $postTypes = get_post_types([ ‘public’ => true, ‘capability_type’ => ‘post’, ]); $postTypes[] = ‘page’; if ( is_array( $postTypes ) ) { $queryArgs[‘post_type’] = $postTypes; } return $queryArgs; }, 15 ); The reason your original code did not include pages is because pages have … Read more
Image inside the content is replaced with featured image from my older post
We can get the total number of posts from the X-WP-Total response header from the /wp-json/wp/v2/posts/ endpoint, e.g. using fetch() in Javascript or apiFetch from @wordpress/api-fetch module in a custom block. Since number of fetched posts doesn’t affect the X-WP-Total header, we can use posts_per_page as 1 and only get the post id field with … Read more
You could load the dashboard widget into its own document in an iframe if the problem is bootstrap css messing up other parts of the page. This answer has example code for the iframe widget part of it: Embed iframe or html page into dashboard widget You just have to pass the iframe a url … Read more
Use custom Javascript for a custom Elementor Widget [closed]