How to add content at the end of posts?

You can simply use get_field that returns the field instead of the_field that echo it. function custom_content_filter_the_content( $content ) { if ( function_exists(‘get_field’) ) { $content .= ‘<span class=”custom_fds”>’ . get_field(‘field1’) . ‘</span>’; } return $content; } add_filter( ‘the_content’, ‘custom_content_filter_the_content’ );

Adding Custom Fields to Search

1) I think that your solution is perfectly acceptable in terms of the “right way” – post meta is intended for searching. Doesn’t seem hacky to me. 2) What you should do is build the meta_query separately: $meta_query = array(); if( !empty( $_GET[‘price’] ) ) { $meta_query[] = array( ‘key’ => ‘_price’, ‘value’ => $_GET[‘price’] … Read more

How to get multiple checkboxes in one meta field

I ended up using Advanced Custom Fields Plugin with get_field( “facilities” ) in my template. I created a Field Group and added facilities as checkboxes. Much faster than checking my code. I would’ve liked to add the checkboxes straight into WooCommerce but this was a time saver and no more time is needed to fix … Read more

How do you create dynamic customised sections in WordPress?

One common way to do similar task is creating a page template. For example: <?php /* Template Name: Reviews and Quotes */ get_header(); ?> <div id=”content”> <div id=”reviews”> <?php $reviews = get_the_reviews(); foreach( $reviews as $review ) { <?php <div class=”review”> ….. </div> ?> } ?> </div> <div id=”quotes”> <?php $quotes = get_the_quotes(); foreach( $quotes … Read more

How to dynamically attach pictures to a carousel

It’s an interesting task. We can make a custom Slider Menu in Dashboard then featured images can be upload from there so that those images can be called dynamically in slider. First we have to make Theme Support and register Post Type in functions.php add_theme_support( ‘post-thumbnails’, array( ‘post’, ‘slider’ ) ); add_image_size( ‘slider-image’, 1024, 550, … Read more

How to sort category by custom field value

Your question it make sense to me my friend but the get_categories don’t have the option to order by “meta_value_num” and then order by custom fields. What you can do is order after you get the array using the usort php function: $all_subcategories = array(‘parent’ => $categoryID); $categories = get_categories( $all_subcategories ); function order_categories($a, $b) … Read more

Custom Fields with get_post()

You already know the ID, so just use it: $customField = get_post_meta($my_id, “_mcf_customField”, true); But only for reference, if you want to get the ID from the object: $customField = get_post_meta($post_id->ID, “_mcf_customField”, true);

Last modified field for user profile?

As mentioned in the comments, you can use the Plugin and Metadata APIs to attach some functionality to the ‘profile_update’ action such that whenever a user’s profile information receives an update, custom user-metadata is set to the time of the update: function wpse216609_update_profile_modified( $user_id ) { update_user_meta( $user_id, ‘wpse216609_profile_updated’, current_time( ‘mysql’ ) ); } add_action( … Read more

Way To Store Global Meta Values

Yes there is Option API to store site global data. You can store some global values using add_option() then can retrive values as get_option() Example: add_option( ‘option_name’, ‘option_value’, ‘deprecated’, ‘yes’ ); //OR update_option(‘option_name’, ‘option_value’, ‘yes’); //Get the value $your_data = get_option(‘option_name’, ‘option_default_value’); echo $your_data;