How to hide a field on the frontend of a Buddypress page by field ID according to user roles and login status?
How to hide a field on the frontend of a Buddypress page by field ID according to user roles and login status?
How to hide a field on the frontend of a Buddypress page by field ID according to user roles and login status?
There’s nothing in your code that would allow this to happen. In your HTML you need to add a selected attribute to the <option> element representing the current value. WordPress includes a helper function, selected() which can help with this: function camere_meta_box_render( $post ){ $number = get_post_meta( $post->ID, “function_camere”, true ); echo ‘<div><select name=”function_camere”>’; for( … Read more
We have various options for achieving this, but I want you to start with the categories since WordPress does not allow a post without a category, which means we won’t miss a post from the following query. Let’s say, you have created a meta using the custom fields to save an accumulated number for each … Read more
Use array_count_values() (untested): <?php $posts = get_posts( array( ‘numberposts’ => -1, ‘category_name’ => ‘bird’, ‘order’ => ‘ASC’, ) ); if ( $posts ) { foreach( $posts as $post ) { $species[] = get_post_meta( $post->ID, ‘species1’, true ); $species[] = get_post_meta( $post->ID, ‘species2’, true ); } } $species = array_filter( $species ); $counts = array_count_values( $species … Read more
I’m quite new to this so I might be the wrong person to answer your question but: get_field(‘allowed_users’) Returns an array of user IDs so you can’t directly use in_array() So if you change the if statement to: if (is_array($allowed_users) && in_array($current_user_id, $allowed_users)) Hopefully it will work.
WordPress’s Twenty Twenty-Four theme makes it possible to add custom fields directly in the editor This UI is not coming from TwentyTwentyFour, and was added to WP decades ago: https://wordpress.org/documentation/article/assign-custom-fields/ It predates 2024/2023 and was even present when the original Kubrick theme was the default theme, this is because it’s a part of WordPress itself. … Read more
No, you did nothing wrong. It’s a known issue and in WordPress v6.1.3 and up to the current stable release as of writing (v6.2.2), it’s happening because of the following lines in get_the_block_template_html() which returns the markup for the current (block-based) template: $content = do_shortcode( $content ); $content = do_blocks( $content ); So as you … Read more
You can set the keys of the array to be user-friendly, but more appropriate would be to define the options array in a function, and then use that function in both the backend and frontend (untested): Array function product_condition_array() { return array( ‘new’ => __( ‘New’, ‘woocommerce’ ), ‘like_new’ => __( ‘New other (see description) … Read more
Search for meta_query does not return any result if combined with title
Multiple permalinks for a single post from custom field