Query posts by custom fields (object post)

If you use Post Object field type, then it is stored as ID in custom field. So this should do the trick: $posts = get_posts(array( ‘numberposts’ => -1, ‘post_type’ => ‘post’, ‘meta_key’ => ‘<FIELD_NAME>’, ‘meta_value’ => <POST_ID> )); PS. You should use ‘posts_per_page’ instead of ‘numberposts’ (which is deprecated).

Adding placeholder text field to woocommerce checkout [closed]

Add the code in your themes functions.php. add_filter( ‘woocommerce_checkout_fields’ , ‘override_billing_checkout_fields’, 20, 1 ); function override_billing_checkout_fields( $fields ) { $fields[‘billing’][‘billing_first_name’][‘placeholder’] = ‘Enter First Name’; $fields[‘billing’][‘billing_last_name’][‘placeholder’] = ‘Enter Last Name’; return $fields; } Solved by adding the code in this way

wordpress select multiple options and illegal string offset ‘timeslot’ [closed]

You are getting illegal string offset ‘timeslot’ because $time is not an array, it is an item in array $timeslots. You have already retrieved the values submitted using $timeslots = $_POST[‘timeslot’]; Your code also contains other typing mistakes. Here is corrected code: <form method=”POST”> <select name=”timeslot[]” multiple=”multiple” size = 4 required> <option value=”1″>1</option> <option value=”2″>2</option> … Read more

Echo piece of code from file

You can do this by putting your piece of code in a function and call it where required just like any template tag. <?php function the_logo(){ ?> <div id=”logo”> <?php if( get_theme_mod( ‘mlwd_logo_image’) ) : ?> <img src=”https://wordpress.stackexchange.com/questions/337491/<?php echo esc_url(get_theme_mod(“mlwd_logo_image’)); ?>” alt=”Logo”/> <?php else: ?> <h1> <a href=”<?php echo home_url(); ?>” title=”<?php bloginfo(‘name’); ?>”> <?php … Read more

HOW TO Insert Existing PHP Code to WOrdPress

Generally speaking, you can typically take PHP code and place a comment at the top: <?php /* Plugin Name: My SOAP Plugin */ ?> You can then create a folder for the plugin inside /wp-content/plugins/ (for example, /wp-conten/plugins/my-soap-plugin/) and place the PHP file inside that folder. At that point, you can activate the plugin from … Read more