Accessing Custom Fields on Pages

Sometimes WordPress is criticized treating everything as a post. The matter of fact is, post type pages, post type post – both are actually Post in database. So no post will collide with any page ID. 🙂 So simply a get_post_meta() is enough. But if you still want something specific to Pages, you can use: … Read more

Concatenate Custom Field Value & HTML Value

To display the_meta () after the ‘by author for’ text just needs a small change: <p style=”text-align:left;font-size:18px;margin-bottom:5px;”><span style=”color: #000000;”>By AUTHOR FOR</span> <?php the_meta (); ?></p> However I’m not sure you want to use the_meta (), because all values get displayed, and in an unordered list. (Reference: the_meta.) Instead you probably want get_post_meta, so: <p style=”text-align:left;font-size:18px;margin-bottom:5px;”><span … Read more

Add two custom fields as a default to the “new post” page.

The below code will add default custom fields to your post ( Insert the code in your themes function.php ) . add_action(‘wp_insert_post’, ‘set_default_custom_fields’); function set_default_custom_fields($post_id){ if ( $_GET[‘post_type’] == ‘post’ ) { add_post_meta($post_id, ‘Field Name’, ”, true); add_post_meta($post_id, ‘Another Field Name’, ”, true); } return true; } By default this will add an empty custom … Read more

Using WP Color Picker in Repeatable Fields

It’s hard to know for sure, since you don’t include the markup you’re output for the metabox nor the JS you’re using to clone. But, the following simplified setup seems to work for me: metabox markup <label for=”my_field”> My Color Picker Field </label> <input name=”my_field” id=’my_field’ type=”text” class=”my-colorpicker” /> <a href=”#” class=”clone-it”>Add Another Color Picker</a> … Read more

WordPress function to add text warning on every pages [closed]

Where do you want it to appear? this function will put something before, or after, the content of each page. function rt_before_after($content) { $beforecontent=”This goes before the content.”; $aftercontent=”And this will come after.”; $fullcontent = $beforecontent . $content . $aftercontent; return $fullcontent; } add_filter(‘the_content’, ‘rt_before_after’); If you want it somewhere in particular let me know … Read more

theme customizer – can a single option pass multiple values?

I understand what you are trying to do, but you are going in the wrong direction here, you can just check if one was selected in your logic and assign the value there like this: function css_customizer(){ $blog_setting_val = get_theme_mod(‘blog_setting’); $opacity_val = ($blog_setting_val == ‘block’) ? ‘1’ : ‘0’; ?> <style type=”text/css”> .blog__Link{display: <?php echo … Read more