Use post ID in functions.php file adminside

It depends on, where you are calling these functions. That is the point, where you enter the var into the function. First, remove the global $post from your functions.php! It makes no sense there! In the functions.php you declare the functions, not call them! I assume, you call your function in some template. So the … Read more

Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)

I believe that your syntax is wrong in the variables you set up in your foreach loop. Because you’re referencing an object and not an array, you need to use this format: $author_ID = $value->ID and… $value->display_name We also discovered that the foreach loop isn’t necessary, so I’m removing it from the answer. The other … Read more

How is $current_page passed in woocommerce_account_orders function?

Action hooks can pass variables do hooked callback functions. For example: do_action( ‘my_custom_action’, $a_variable ); For that action, any callback function has access to $a_variable: add_action( ‘my_custom_action’, ‘my_custom_function’ ); function my_custom_function( $a_variable ) { // etc. } The woocommerce_account_orders_endpoint action hook is defined like this: do_action( ‘woocommerce_account_’ . $key . ‘_endpoint’, $value ); Where $value … Read more

Create page template via functions.php?

Your previous question, Possible to create a “variant” page template that only contains differences and is therefore resilient to updates of original (ie page.php)?, provided nicely more context to this question. As you Sally CJ noted in the comments you use theme_page_templates to add custom template to the template select list. To skip adding a … Read more

Upload multiple files in randomly generated folder using wp_upload_bits

Apply the following fixes (those with the // Fix <number>: comment) and your code would work in that only one random folder that will be created for all the uploads in the current session: (Note: I presumed the $countfiles is properly defined in your actual code.) function file_upload_callback() { global $wpdb; $table_name=”wp_order_quotes_real”; $_filter = true; … Read more

How to keep the capability of users and disable Gutenberg editor in WordPress?

add these lines in your ‘functions.php’, it will work //if not gutenberg reapprove posts add_filter( ‘wp_insert_post_data’, ‘re_aprove’, ’99’, 2 ); function re_aprove( $data, $postarr ) { //check if current user is not admin if ( ! current_user_can( ‘manage_options’ ) ) { if ( ‘publish’ === $data[‘post_status’] ) { $data[‘post_status’] = ‘pending’; } } return $data; … Read more

how to save checkbox data for custom setting?

Your checkbox data is saved as 1 or ” if someone checked or unchecked it. you can also verify this using var_dump($checkbox) inside custom_checkbox_field_html function This should work. function custom_checkbox_field_html(){ $checkbox = get_option( ‘disabletitle_text’ ); $is_checked = ( $checkbox != ” && $checkbox == 1 ) ? ‘checked’: ”; printf( ‘<input type=”checkbox” id=”disabletitle_text” name=”disabletitle_text” value=”1″ … Read more