WordPress.org Forums » All Posts https://wordpress.org/support/forum/wp-advanced/feed/ Wed, 14 May 2025 21:02:33 +0000 https://bbpress.org/?v=2.7.0-alpha-2 en-US https://wordpress.org/support/topic/custom-start-and-build-scripts-with-experimental-modules-not-working/#post-18464386 <![CDATA[Reply To: Custom start and build scripts with –experimental-modules not working]]> https://wordpress.org/support/topic/custom-start-and-build-scripts-with-experimental-modules-not-working/#post-18464386 Wed, 14 May 2025 00:58:23 +0000 bejuco Got it, had to move every block to the src folder and use only one start/build script with the –experimental-modules flag and it will build correctly.

]]>
https://wordpress.org/support/topic/custom-start-and-build-scripts-with-experimental-modules-not-working/#post-18464111 <![CDATA[Custom start and build scripts with –experimental-modules not working]]> https://wordpress.org/support/topic/custom-start-and-build-scripts-with-experimental-modules-not-working/#post-18464111 Tue, 13 May 2025 19:16:28 +0000 bejuco Hello, I’m trying to create an block that uses the Interactivity API following this guide.

When I create it in its own folder with its own package.json, everything works as expected. But when I try to create it in a folder with other blocks with a package.json with custom build and start scripts for each block, the block is registered and rendered but the interactivity won’t work. I get a Uncaught TypeError: _wordpress_interactivity__WEBPACK_IMPORTED_MODULE_0__ is undefined.

The script in the package.json is: “start:custom”: “wp-scripts start –experimental-modules –source-path=./custom/src –output-path=./custom/build”.

The difference I’ve seen is in the built view.js files. One starts with import * as WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257 from “@wordpress/interactivity”; and the other with (() => { // webpackBootstrap “use strict”; .

Am I missing something? I’m using “@wordpress/scripts”: “^30.14.1”

]]>
https://wordpress.org/support/topic/how-to-write-tests-for-gutenberg-via-mocking-useselect-or-via-a-dummy-post/#post-18463600 <![CDATA[Reply To: How to write tests for Gutenberg via mocking useSelect or via a dummy post?]]> https://wordpress.org/support/topic/how-to-write-tests-for-gutenberg-via-mocking-useselect-or-via-a-dummy-post/#post-18463600 Tue, 13 May 2025 14:34:41 +0000 Jaydeep Das Hi @cherrygot,
If you are getting undefined when trying to fetch metadata using getEditedPostAttribute, it can be because meta fields are not registered properly for the Post Type in PHP. Make sure that show_in_rest is true for the Post Type.

For this:

The entity being edited (postType, undefined) does not have a loaded config.

I believe what is happening is your code ran before the Post Type could be registered. It is weird because post is a default Post Type and should have worked out of the box.

Maybe you can try out something like this done in core-data test.

]]>
https://wordpress.org/support/topic/issues-with-allowedblocks-not-letting-core-navigation-link-be-inserted/#post-18462666 <![CDATA[Reply To: Issues with AllowedBlocks not letting core/navigation-link be inserted]]> https://wordpress.org/support/topic/issues-with-allowedblocks-not-letting-core-navigation-link-be-inserted/#post-18462666 Tue, 13 May 2025 06:58:30 +0000 Tushar Bharti Hi @timerabbit07,

Looking at the core/navigation-link source code, it checks whether it’s nested inside a core/navigation block. In the current code snippet, it’s not within a core/navigation block, which is why it’s not appearing in the InnerBlocks.

A possible workaround would be to include core/navigation in the allowedBlocks prop and update the snippet to act as a wrapper for it. This way, the core/navigation-link block will be available again inside the navigation block.

Regards

]]>
https://wordpress.org/support/topic/the-path-in-function-php-for-js-file-is-not-been-recognizing-in-child-theme/#post-18461937 <![CDATA[Reply To: the path in function.php for js file is not been recognizing in child-theme?]]> https://wordpress.org/support/topic/the-path-in-function-php-for-js-file-is-not-been-recognizing-in-child-theme/#post-18461937 Mon, 12 May 2025 16:42:45 +0000 johannes999 thanks for information

]]>
https://wordpress.org/support/topic/the-path-in-function-php-for-js-file-is-not-been-recognizing-in-child-theme/#post-18461930 <![CDATA[Reply To: the path in function.php for js file is not been recognizing in child-theme?]]> https://wordpress.org/support/topic/the-path-in-function-php-for-js-file-is-not-been-recognizing-in-child-theme/#post-18461930 Mon, 12 May 2025 16:39:37 +0000 bcworkz You’re welcome! FWIW, the problem you encountered where you upload an edited file and it ends up breaking your site is not uncommon. The way to correct the problem is to access your server’s error log. The error that broke the site should be the last logged entry, giving you a good clue towards what and where the error was. Then attempt to find and correct the actual error. This can be difficult at times. Not all errors are obvious even when you have an error message to go on.

It’s good practice to always keep a known good backup copy of any file you’re editing so site functionality can be easily restored without needing to find and correct an error. If you very frequently test any code edits, the error that needs correction will invariably be the last bit of code you altered.

]]>
https://wordpress.org/support/topic/adding-a-gettexed-element-after-the-category-term/#post-18461916 <![CDATA[Reply To: Adding a gettexed element after the category term]]> https://wordpress.org/support/topic/adding-a-gettexed-element-after-the-category-term/#post-18461916 Mon, 12 May 2025 16:25:55 +0000 bcworkz Adding gettext will not solve the problem. If ‘bcn_breadcrumb_title’ filter does not let you alter a particular breadcrumb, you’ll likely need to rely on related WP filters like “get_category” or “the_title”. The right filter depends upon the nature of any particular breadcrumb item.

]]>
https://wordpress.org/support/topic/daily-posts-plugin/#post-18461208 <![CDATA[Reply To: Daily Posts plugin]]> https://wordpress.org/support/topic/daily-posts-plugin/#post-18461208 Mon, 12 May 2025 10:10:32 +0000 threadi The code is syntactically and contextually correct, but does not comply with WordPress Coding Standards. These are basics according to which plugins and themes in WordPress should be developed. See: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/

If it works for you, use it. I would recommend integrating the code via a code snippet plugin if you don’t want to make your own plugin out of it. For future codes, however, it might be better not to rely on an AI, as these could also contain security vulnerabilities.

]]>
https://wordpress.org/support/topic/daily-posts-plugin/#post-18461104 <![CDATA[Reply To: Daily Posts plugin]]> https://wordpress.org/support/topic/daily-posts-plugin/#post-18461104 Mon, 12 May 2025 09:17:19 +0000 Mainul Kabir Aion Hi,

Its better to create a custom plugin and update when needed. Otherwise, it will be removed when you update the core WordPress version. If the code works, go for it!

Thanks.

]]>
https://wordpress.org/support/topic/daily-posts-plugin/#post-18460839 <![CDATA[Daily Posts plugin]]> https://wordpress.org/support/topic/daily-posts-plugin/#post-18460839 Mon, 12 May 2025 06:55:52 +0000 Richard Brown Hi

I had this idea a while ago to create a plugin to show the posts on today excluding category and year. I asked Gemini to help with the code and this is what it has come up with:

<?php

/**

* Shortcode to display posts published on the current day and month, across all years.

*

* Usage: [daily_on_this_day_posts]

*/

function display_daily_posts_on_this_day_shortcode() {

// Get the current day and month

// 'j' for day of the month without leading zeros (1 to 31)

// 'n' for month number without leading zeros (1 to 12)

$current_day = date('j');

$current_month = date('n');

// Arguments for the WordPress query

$args = array(

'post_type' => 'post', // We are querying standard posts

'post_status' => 'publish', // Only show published posts

'posts_per_page' => -1, // Retrieve all posts that match the criteria

'date_query' => array( // This is the key part for matching the date

array(

'month' => $current_month, // Match the current month

'day' => $current_day, // Match the current day

// Year is intentionally omitted to match across all years

),

),

'orderby' => 'date', // Order the results by their full publication date

'order' => 'DESC', // Show the newest posts first (e.g., from most recent year)

'ignore_sticky_posts' => 1, // Do not let sticky posts interfere with the date order

// By default, WP_Query searches all categories, so no need to specify category exclusion explicitly

);

$daily_posts_query = new WP_Query($args);

// Prepare the output string

$output = '';

// Get the current date formatted nicely for the title (e.g., "May 12th")

$current_date_formatted = date('F jS'); // Using 'F jS' for "Month daySuffix", e.g., "May 12th"

if ($daily_posts_query->have_posts()) {

$output .= '<h2>Posts from ' . esc_html($current_date_formatted) . ' (Across All Years)</h2>';

// Removed the <ul> tag

while ($daily_posts_query->have_posts()) {

$daily_posts_query->the_post();

// Each post is now a separate div block

$output .= '<div class="daily-post-entry" style="margin-bottom: 30px; padding-bottom: 20px; border-bottom: 1px solid #eee; overflow: hidden;">'; // Added overflow:hidden to contain floats

// Display the featured image if it exists, floated to the left

if (has_post_thumbnail()) {

// You can change 'thumbnail' to other sizes like 'medium', 'large', or a custom size

// Added float:left and margin for spacing

$output .= '<div class="daily-post-image" style="float: left; margin-right: 15px; margin-bottom: 10px; max-width: 150px;">'; // Added max-width to control image size

$output .= get_the_post_thumbnail(get_the_ID(), 'thumbnail'); // Using 'thumbnail' size

$output .= '</div>';

}

// Container for the text content, to allow it to flow next to the image

$output .= '<div class="daily-post-content" style="overflow: hidden;">'; // overflow:hidden helps contain content next to float

// Display the post title as a link

$output .= '<h3><a href="' . esc_url(get_permalink()) . '">' . esc_html(get_the_title()) . '</a></h3>';

// Display the full publication date

$output .= '<p style="font-size: 0.9em; color: #555; margin-top: 0;">Published on: ' . esc_html(get_the_date('F jS, Y')) . '</p>'; // e.g., May 12th, 2023

// Display the excerpt

$output .= '<div style="margin-top: 5px;">' . get_the_excerpt() . '</div>';

$output .= '</div>'; // End of daily-post-content

// $output .= '<div style="clear: both;"></div>'; // Optional: explicit clear if overflow:hidden on parent isn't enough in some themes

$output .= '</div>'; // End of daily-post-entry

}

// Removed the </ul> tag

wp_reset_postdata(); // Important: Restore original post data after custom loop

} else {

$output .= '<p>No posts found for ' . esc_html($current_date_formatted) . ' from any year.</p>';

}

return $output; // Return the HTML to be displayed by the shortcode

}

// Register the shortcode so WordPress recognizes it

add_shortcode('daily_on_this_day_posts', 'display_daily_posts_on_this_day_shortcode');

?>

Should I simply post the code in the functions file or would it be better to create a plugin and update on a regular basis please? Is the code ok?

Thanks

Rich

]]>