Title: Custom fields
Last modified: August 20, 2016

---

# Custom fields

 *  Resolved [magicspon](https://wordpress.org/support/users/magicspon/)
 * (@magicspon)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/custom-fields-75/)
 * Hello,
 * I am using this plugin with the Advanced Custom Fields (acf v.4) plugin. I’ve
   been able to add custom fields to my content blocks. Now I just need to get them
   to display in my widget.
 * I have asked for some assistance on the ACF forum, the develop has come back 
   to me and asked if I have the post_id variable for the content block
 * link: [http://support.advancedcustomfields.com/discussion/5449/add-custom-fields-to-widget](http://support.advancedcustomfields.com/discussion/5449/add-custom-fields-to-widget)
 * At the moment I have had to pass in the post ID in order for the custom field
   to display in my theme. (Using the Warp theme framework from yootheme).
 * Here is the code:
    ` <div class="module <?php echo $style; ?> deepest"> <?php
   echo $badge; ?> <?php if ($showtitle) echo $title; ?> <?php echo $content; ?>
   <?php the_field('panel_link',803); ?> </div>  <?php the_field(‘panel_link’,803);?
   > is my custom field, and 803 is the ID of the post.
 * Obviously for this to work I can’t hardcode in the ID of the post.
 * I can see a previous post has asked a similar question but it is marked as resolved
   so I am unable to comment on it.
 * Any help, greatly appreciated
 * Thanks
    Dave
 * [http://wordpress.org/extend/plugins/custom-post-widget/](http://wordpress.org/extend/plugins/custom-post-widget/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Thread Starter [magicspon](https://wordpress.org/support/users/magicspon/)
 * (@magicspon)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/custom-fields-75/#post-3621471)
 * Sorted
 * in my widget code i’ve added in the following line:
 * Which gets the custom field and the ID of the content block
    `<?php the_field('
   panel_link',$customPostId); ?>`
 * I’ve set $customPostId) in the module.php file in the warp framework
 * `$customPostId = (!empty($module->params['custom_post_id']))? $module->params['
   custom_post_id'] : null;`
 * Cheers
 *  [Senff – a11n](https://wordpress.org/support/users/senff/)
 * (@senff)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-75/#post-3621589)
 * I’m having the same issue but I’m not sure how to go about this.
 * My Content Blocks have 2 custom fields. So how do I display them on my site? 
   Currently it only shows the title and the content, and I want to add the values
   of the custom fields.
 *  Thread Starter [magicspon](https://wordpress.org/support/users/magicspon/)
 * (@magicspon)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-75/#post-3621590)
 * Are you using the Warp framework from yootheme?
 * If you are.. this is the code for one of my custom blocks
 *     ```
       <div class="module <?php echo $style; ?> deepest">
       	<?php echo $badge; ?>
       	<div class="title">
       		<i class="icons icons-icon_bulb_big"></i>
       		<?php echo get_field('cb_heading',$customPostId); ?>
       	</div>
       	<div class="message">
       		<?php echo $content;?>
       	</div>
       </div>
       ```
   
 *  [Senff – a11n](https://wordpress.org/support/users/senff/)
 * (@senff)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-75/#post-3621591)
 * Nope, I’m not…. I just wanted to place the custom fields in the widget code (
   regardless of the theme), and I managed to do that.
 * So let’s say I have a custom field (using Advanced Custom Fields) called “event_description”
   that is added to my Content Blocks.
 * In \wp-content\plugins\custom-post-widget\post-widget.php, in the function “widget”(
   starting at line 82), I added the following lines in the part where the widget
   is being written:
 *     ```
       $evt_desc = get_field('event_description',$custom_post_id);
       if ($evt_desc) {echo $evt_desc;}
       ```
   
 * The result is that the value of that custom field is then being displayed in 
   the widget on the front end.
 * It’s very simple! 🙂
 *  Thread Starter [magicspon](https://wordpress.org/support/users/magicspon/)
 * (@magicspon)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-75/#post-3621592)
 * sorry, I don’t really know WordPress and my php is lacking.. can’t really help
   you I’m afraid. Have you looked on stackoverflow.com
 * good luck
 *  [Senff – a11n](https://wordpress.org/support/users/senff/)
 * (@senff)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-75/#post-3621593)
 * Hmmmm no, I don’t need help anymore, in my previous post I wrote the solution.
   🙂
 *  Thread Starter [magicspon](https://wordpress.org/support/users/magicspon/)
 * (@magicspon)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-75/#post-3621595)
 * hhaha.. sorry! too many beers and dev! ;}

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Custom fields’ is closed to new replies.

 * ![](https://ps.w.org/custom-post-widget/assets/icon.svg?rev=2884166)
 * [Content Blocks (Custom Post Widget)](https://wordpress.org/plugins/custom-post-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-post-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-post-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-post-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-post-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-post-widget/reviews/)

## Tags

 * [ACF](https://wordpress.org/support/topic-tag/acf/)
 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [widgets](https://wordpress.org/support/topic-tag/widgets/)

 * 7 replies
 * 2 participants
 * Last reply from: [magicspon](https://wordpress.org/support/users/magicspon/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-75/#post-3621595)
 * Status: resolved