How to Display Custom Meta Box only on Specific Page IDs

A simple and cleaner solution would be to use !in_array ex: function mf_1_remove_meta_boxes() { if( !is_admin() && !isset( $_GET[‘post’] ) ) return; if( !in_array($_GET[‘post’], array(‘194′,’185′,’2’) ) ) remove_meta_box( ‘mf_1’, ‘page’, ‘normal’ ); } this way you can just add the ids in the array and as many as you want

How to enable Custom Fields that are disabled by theme?

Create a Child Theme, Plugin or Must Use plugin, and use add_post_type_support: <?php /* Plugin Name: Add CF to CPTs */ add_action( ‘plugins_loaded’, ‘add_cpt_support_wpse_116891’ ); function add_cpt_support_wpse_116891(){ # See /wp-admin/edit.php?post_type=SLUG add_post_type_support( ‘SLUG-POST-TYPE-1’, array( ‘custom-fields’ ) ); add_post_type_support( ‘SLUG-POST-TYPE-2’, array( ‘custom-fields’ ) ); add_post_type_support( ‘SLUG-POST-TYPE-3’, array( ‘custom-fields’ ) ); }

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 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);

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;

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)