weweloo
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Issue with Block Theme Templatestemplate-canvas.php is a core file in WordPress located in the wp-includes folder. I don’t want to modify any files outside of the theme, as it would impact future WordPress updates. I prefer making all changes within the theme files.
Forum: Developing with WordPress
In reply to: Issue with custom rewrite rules for custom post types.Thank you very much for your suggestions. I’ve tried these methods, but it seems that they don’t meet my requirements. I’ve registered a custom post type named “work,” and by default, the URL for the posts is like https://dotmain.com/work/post-slug. However, I wish to change the URL to something like https://dotmain.com/2828ea92b889oc78. I’m using a fixed string generated through
substr(md5($post->ID), 0, 18)
for encoding. Unfortunately, when I open the page, it returns a 404 not found error.Forum: Developing with WordPress
In reply to: The issue with using WP_QueryI tried your method, but still couldn’t get the results. I switched to using a database query approach, and that allows for precise matching.
global $wpdb; $sql = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='meta_key' AND meta_value like '%:" . esc_sql($post_id) . ";%'"; $found_posts = $wpdb->get_col($sql); if (empty($found_posts)) $found_posts = [0]; $query_args = array( 'post_type' => 'work', 'post_status' => 'publish', 'posts_per_page' => 10, 'post__in' => $found_posts );
Forum: Developing with WordPress
In reply to: The issue with using WP_Querychange to ‘compare’ => ‘LIKE’ resolved.
Forum: Developing with WordPress
In reply to: The issue with using register_meta() to register metadata.Perfect, thank u.
I change the register code into
register_meta('post', '_mk_post_thumbnail', array( 'single' => true, 'type' => 'array', 'show_in_rest' => array( 'schema' => array( 'items' => array( 'type' => 'object', 'properties' => array( 'mediaType' => array( 'type' => 'string', ), ), ), ), ), 'auth_callback' => function () { return current_user_can('edit_posts'); } ));
- This reply was modified 11 months ago by weweloo.
But this method requires a block to be added to the content area. Is there a way to automatically add a piece of css code that can be dynamically modified when the page is created?
Forum: Developing with WordPress
In reply to: Use save_post to generate file.The issue fixed.
if (false == wp_is_post_revision($post_id)) {
…
}- This reply was modified 1 year, 11 months ago by weweloo.
Forum: Fixing WordPress
In reply to: How can I remove the inline style in block editor.It is look like that remove the styles on frontend but not backend. Is any way to remove all inline styles on the backend?