Advanced Custom Field Widget

Advanced Custom Field Widget is a plugin for WordPress. Based on the original Custom Field Widget by Scott Wallick, and released under the GPL, ACFW allows you to drag content from custom fields attached to posts and pages and turn it into useful HTML for your WordPress powered sidebars.

The homepage for information about ACFW is now my wiki, but if you’ve got comments, then please leave them here on this page.

You can download ACFW from the WordPress plugin directory here.

You can skip to the end and leave a response. Pinging is currently not allowed.

67 Comments

  • baron says:

    hi. Thanks for plugin

    perfect.

    Regards

  • Thanks for the feedback guys. Glad you like it.

    Scott: As I said in the readme… thanks for writing the original.

  • Hi,

    Thanks very much for the useful plugin. It’s great.

    I have discovered a problem though. The plugin seems to conflict with WordPress’ built in “Recent Posts” widget.

    I’m using WordPress 2.7 and v4.0 of your plugin, and I have configured the “primary custom field key” to be custom_sidebar_html1, and then I added a custom field (with a key of custom_sidebar_html1) to a specific page (about page).

    When the widget is placed above the recent post widget, it works as expected (the specific page displays the custom field’s value. However if I move the widget so it’s below the recent posts widget, then no content is displayed. The widget seems to be using the post id of the last post in the recent posts widget, so it never finds the custom field that is set for the page.

    Apart from this, everything seems to work.

    Do you have any idea how to fix this?

    Thanks!

    • Hi James,

      Thanks for the feedback.

      With regards to the problem you are experiencing, leave it with me… I’ll have a nosey through the code and see if I can come up with a fix.

    • Hi James,

      I’ve had a look at this problem over lunch, and I think I’ve got a fix. If you do a manual download of the development version, specifically ‘advanced-custom-field-widget.php’, it should be fine and operating as expected.

      I’ve tried it out on my slightly out of date development site on my laptop and it seems fine, so let me know how you get on with this fix and if it’s all good, I’ll tag up version 0.5.

  • will says:

    I posted this elsewhere here but the code might have mucked it up so I thought I’d put it in this thread shorter and sweeter.

    I am trying to inject the custom field as just one part of a link.

    EG somesite.com/abc/ThisIsTheCustomField.search

    The pretext is: blah blah blah somesite.com/abc/
    The posttext is: .search blah blah blah
    The custom field is: ThisIsTheCustomField

    But when I do that the resulting link is:

    somesite.com/abc/ThisIsTheCustomField.search

    which breaks the link.

    Any ideas on how to inject part of a link without the div messing t up?

    • will says:

      Bah! It stripped the code away this time. That resulting link should say:

      somesite.com/abc/ ThisIsTheCustomField .search

      Here’s hoping the scode spaced out breaks it up and it won’t get stripped.

      • will says:

        And it was, again.
        That resulting link should say:

        somesite.com/abc/ ( div class = ‘ advancecustomvalue ‘ ) ThisIsTheCustomField ( / div ) .search

        with all brackets naturally being ><

  • Hi Will,

    What you want to do ties in nicely with a change I’ve been pondering for a little while, so I’ll see what I can do within the next day or so if you can bear with me :-)

  • Bill W says:

    I think I like this plugin …. seems complicated, but that’s good in this case.

    Here’s a problem: when trying to pull the url for an image out of a custom field, wrapping it using pre and post text so the image will appear and not just output the url, this is the output to the page:

    looks like it’s trying to add some class div before and after my pre and post … ideas?

    Also, the other thing I would like to do is have this image display, but also make that a link to the post it comes from … ideas how I can do that?

    thanks for your work!

    • Bill W says:

      i hate this no code in comments!

      okay, hopefully this will work and you’ll get the idea …

      %3Cdiv%20class=%27advcustomvalue%27%3E%0Ahttp://www.cchange.net/wp-content/uploads/2009/04/johnelkington1-150%C3%97150.jpg%0A%3C/div%3E”

      please email me if this code doesn’t appear.

  • Hey Will,

    Your plug-in may be a miracle for me, but my little brain has trouble figuring it out. My site is intent on offering different organizations a place to post their localized news and calendar info on an individualized page. The news comes by way of RSS feed and the calendar by way of icalendar.

    Problem: I can’t use the widgets obviously, because I get the same content on each page. When I embed my individualized content in the page/post directly, without the formating aid of a widgetized area, it doesn’t show up nice and neat as in a widget, but rather haphazardly across the page. I have been trying to figure out how to create custom fields for this purpose, but the learning curve is too high for me. Can this plug-in make the process easier?

    • Firstup… it’s not Will’s plugin, it’s mine… but that minor error aside, I’m not quite sure what you want to do.

      The Advanced Custom Field Widget is for displaying the content of custom fields in a sidebar widget. If you take a look at my site, the Amazon side bar is the ACFW loading content from pages where I’ve reviewed something. It doesn’t pump data into the custom fields, it just makes displaying whats there fairly simple. If you can provide a bit more information and possibly an example page or something, then I may be able to give you a better answer.

  • So sorry for the name mix-up. I got excited.

    Despite the best of intentions, I’m not smart enough to get this stuff. If you look at http://www.mpoweredparent.com, you’ll see a newsfeed at right sidebar. “Drunk Driving in the News”. It displays nice and pretty because it’s in a widget. Now check out http://www.mpoweredparent.com/rpa . That is a test page that I have been thumping away at for over a week now. It displays an individual rss feed that was custom selected for that page. The problem is that in order to select a custom feed for that page, I have to embed the feed into the post, rather than simply drop it into a widget. As a result, formatting goes out the window, and the feed displays across the entire page.

    My goal is for the AthenaOfDelphi Organization to be able to have their own page/post, with a localized news feed, and secondly, their own icalendar feed display in a nice neat “widget-like” area of the page. Ultimately, I’ll have dozens of these pages, and would like them to look uniform, but for the customized content. Using widgets, I would be stuck with the same feed and icalendar content on each page. Thanks again for your time and wisdom. -T

  • Yanik says:

    Hello AthenaOfDelphi,

    First i want to thank you for this great plugin which is so wonderfully close to what I need for my site.
    I was wondering if there was a quick and dirty way to have 3 different calls per page such as:
    custom field ‘amazon-linkto’ with value to 204
    custom field ‘amazon-linkto’ with value to 206
    custom field ‘amazon-linkto’ with value to 208
    And have the 3 displayed in the same sidebar at the same time?

    thanks for any further help you may provide.

    Cheers
    Yanik

    • Hi Yanik,

      At the moment, no because the widgets will all pick up the first instance of the ‘amazon-linkto’ field so they’d all point to the same page.

      However, thats not to say that it can’t do it. I’ve sent you a mail to discuss further.

  • Will says:

    Looks like something broke. I just upgraded from WP 2.86 where everything was just fine to WP2.9. This required a database dump and upgrade to mysql5. Got everything running but the ACFW now shows every widget whether a custom field was used or not (ie if no cf used then it shows a blank widget). Any ideas if this a WP2.9 issue or something I can correct in the database?

    • Hi Will,

      I’ve just released version 0.82 of the widget, which should fix the problem you’re having. It appears to have been caused by a minor change in functionality (or a bug fix) in one of the WordPress functions I was using to retrieve the custom field data. When I upgraded the development copy of my blog to WP 2.9, I got the problem you’re experiencing… widget version 0.82 has fixed it, so give it a try and let me know how you get on.

      Athena

  • karin says:

    Hi,

    I just found your plugin. Hoped it would work on my page, but it doesn’t. The page I want to use it for is not a regular WordPress page, but it’s a page with three blocks with the loop, each showing the lastest post of a certain category. The ACFW are working perfecty on a normale page, but not on this page. The sidebar is okay. there is one normal textwidget and that is showing, but the CF widgets aren’t. Is there a way to show the widgets on a page with multiple loops?

    • karin says:

      Got my friend making some changes to the code. It’s working now.

      • I’m not sure myself as I’ve only ever had one loop… but clearly you’re friend has made it work. If you could send me the modified code, I can look at including the changes in a later release which may of course help other people out as well.

        And another thing… where’s your site so I can have a look at it in situ? :-)

  • acordero says:

    Athena, would it be possible to allow shortcodes in the content? I tried but it returns them as html, and using do_shortcode returns nothing.

    • Hi Antonio,

      As far as I know the shortcode works and will generate the widget as it would be generated for the sidebar. Certainly on my test installation if I include the shortcode [acfw id="WIDGETID"] it works fine. The WIDGETID corresponds to the widget ID given in the widget control panel.

      If you can send me sample configuration information and sample data from a page, I can look into it. Could be it’s just a minor configuration issue that could be addressed by improving the on-line user manual.

      I forgot to add when I originally posted… it is version 0.9+ you are using? If not, you’ll have to upgrade to that as the shortcode functionality was only added in 0.9+.

      Regards

      Christina

    • Antonio,

      I’ve mailed you requesting a bit more information. Reply to the mail providing some sample data/config etc. and I’ll see what I can do. I also think I misinterpreted your question with my original reply so I’d also like clarification on that (it’s all in the email).

      Regards

      Christina

  • John A says:

    If you put:
    for PRETEXT
    for POSTTEXT

    the output will be

    sample text

    if you put no PRETEXT or POSTTEXT you get
    sample text

    • Hi John A,

      Unfortunately HTML isn’t allowed in comments. I have dropped you a mail asking for clarification/sample data as I’ve just tested pre and post text and they appear to work as expected. When you get the mail, reply providing some sample data/configuration and a brief explanation (if it isn’t obvious from the data) and I’ll see what I can do.

      Regards

      Athena

  • Holger says:

    Hi,
    is it possible to build a widget with multi custom field values and some if statements in it?

    I want to use the costom fields and the acfw for displaying some social urls like
    website
    facebook
    twitter
    youtube
    etc

    I played around and get it work with the content generator field and the additional data fields. My problem is only, I dont always have all the additional data fields in every post.

    Website is the main custom field and always present but I want something like
    website
    if $facebook then a href $facebook
    if $twitter then a href $twitter
    if $youtube then a href $youtube

    courrently I have dead links if there is no value for the custom field.

  • Matt says:

    Hi,

    Firstly thanks for the further development of such a great plugin.

    However I was wondering how I could execute wordpress shortcodes within the widget the plugin produces? At the moment I have the following wordpress shortcode set as a custom field-

    [ds title='8MP Digital Camera' clickref='digitalcameras' query="+8mp +camera"]

    But when you view the post on the front end, all it outputs is what I have written above and doesn’t actually execute the shortcode.

    After a bit of reading I found that you can enable the processing of short code in the text widget by adding the following into your functions.php file-

    add_filter( ‘widget_text’, ‘do_shortcode’);

    ANd that works perfectly for the text widget, but I want to execute shortcode within your custom field widget.

    I have looked through the plugin to see how/where I could add that line of code but nothing seems to work.

    I’m sure its a simple thing to do, but for the life of me I cannot work it out!

    Please help, i’ll buy you a beer via paypal :)

    Thanks for your time

    • Matt,

      I’ve dropped you a reply by email along with a slightly custom version of the main widget file. As you’ve probably read, I’m working on version 1.0.0 of the widget now, so I’ll be sure that this functionality is included in it.

      Regards

      Christina

      • dcole says:

        I’m attempting to do something similar (maybe the reverse?) — hoping to drop in a custom field as a variable in another set of shortcode:
        tried to put this in the content generator but either shows nothing or just repeats the code as text.
        [slickr-flickr tag="$data1" type="gallery" captions="off" thumbnail_size="square" items="2"]

        (there is a php equivalent for that shortcode which works but much easier to use shortcode)

        thanks!

    • Noizeburger says:

      Hy, I’m in need of the same function (parse a shortcode and output it through your widget)! Any news on this?

      Thanks in advance,

      Harald

      • Hi Noizeburger,

        There is news… following your comment, I’ve released the version of the code I’ve released to these guys. It should process shortcodes in the content just as requested. It’s available here.

        Please let me know how you get on with this. I didn’t give it a great deal of testing because I was pushed for time and as yet, I’ve not received anything back from the other guys who also requested this.

        Regards

        AthenaOfDelphi

        • Noizeburger says:

          Hi again,

          First of all, thank you for this quick response.

          I have updated to 0.99 – without success. What I’ve done: created a custom field “Rating” with the value – a shortcode like “[Rating:4.5/5]” . I’ve created a widget with the key “Rating” as primary key.

          The output is [Rating:4.5/5]. It should be star-images.

          Or did I just understand the whole thing wrong?

          Thanks

  • dcole says:

    Sorry to bother you again. Maybe I missed something but is there a way to get it to work when viewing the ‘main’ page – ie: aggregate listing of latest posts? I can see why it wouldn’t work in the sidebar (no single post to get a value from ) for the main page, but it is also not displaying when I drop the shortcode into an individual post’s main content. Or maybe it wasn’t intended for that usage?
    thank you again!

    • Hi dcole,

      I’ve dropped you a mail asking for some information about how you’re planning on using the widget. I’ve kind of gotten myself confused a little about how you plan on using it. Reply to that mail with the info I’ve asked you for and I’ll see what I can do/suggest to get you up and running.

      Regards

      Athena

  • Noizeburger says:

    Yeah! I’ve changed the rating plugin – now the shortcodes work.

    Thank you

  • Dave says:

    Hello,
    I installed ACFW and Virtual Sidebar to my WordPress site and what I’m trying to do is add a custom Amazon MP3 Clips Widget to a single post, but I have no idea what to put where in the WordPress interface. I’ve tried many different things according to the instructions of the plug-in but I’m pretty sure I’m doing something wrong. Plus, the code Amazon gave me for the widget is confusing to me.

    Edit – Code removed (Athena)

    Your help would be much appreciated.

    • Dave says:

      *Update*
      Ok, it appears I had everything right after all using the Virtual Sidebar it actually works really well in IE. The problem here is with Firefox. I noticed that the mp3 widget wasn’t working in other people’s blogs as well which I knew couldn’t be right, so I switched over to Internet Explorer and everything works just fine. I think Firefox is having a problem with the Flash part but I haven’t figured out what it is yet.

      • Hi Dave,

        Glad you got it sorted. If you are having problems with ACFW or Virtual Sidebar and still need assistance, let me know and I’ll drop you an email (it’s generally much easier to sort problems over email or a messenger chat).

        Regards

        Athena

        P.S. Just had a look at your site and I believe the problem with Firefox may actually be something as simple as the NoScript plugin as I had to enable a number of scripts in NoScript before the widgets would work.

        • Dave says:

          Thanks for your help Athena. It was actually the AdBlock Plus plugin preventing the widget from working, which it gives users no warning what-so-ever, so I guess I will put some sort of notice on the site about that. BTW, Virtual Sidebar is an awesome plugin.

          Dave

          • Hi Dave,

            Thanks for the feedback, and a big thanks for the feedback on Virtual Sidebar, it’s much appreciated.

            If you do get any problems with either of my plugins or you have ideas etc. which may help make them better, please don’t hesitate to let me know :-)

            Regards

            Athena

  • Shane says:

    Hi there Athena,

    Hi Athena,

    Firstly, I have been testing this plugin against other Custom Field plugins and I must say I love the plugin.

    I am still only testing my site (not public yet.

    One question however.

    I have included HTML tags in my custom fields entered when creating a New Page – not manually entered in widget.
    Is there away to allow the ACFW render the HTML as it just produces everything AS IS so I see the markup?

    Issue in all Custom Field plugins I have used, so not limited to your plugin.

    Regards

    Shane

    • Hi Shane,

      I’ve dropped you an email with a few questions in. Let me know if you don’t get it.

      Regards

      Athena

      • Shane says:

        Hi there Athena,

        That was super fast, thank you so much.

        I have just discovered that the issue lies not with the ACFW.
        I was using it in conjunction with another plugin, “Sidebar Tabs” and it is with this plugin the fault lies.
        ACFW renders HTML perfectly used on its own.

        My apologies and deep gratitude once again.

        Shane

  • Dave says:

    Hi, I’m really missing something here, I’m not sure if I’m using this correctly or not.

    Simply put, I have a custom field for called “camera”, all lower case, and that are related to this field have a free text value for the camera field.

    What I am trying to do, is have a list of all the camera types in my sidebar.

    Is this the intent of this widget? No matter what I put where in this widget, I don’t get a list of cameras

    • Dave says:

      I really did word that second line badly:\, what I meant to say was:

      I have a custom field in my posts called “camera”, which is filled with a free text value.

      What I want to do is have a list of camera types in the sidebar.

      • Hi Dave,

        ACFW is designed to display the content of the fields attached to a particular post. It’s not designed to collect together the data from the same field across your blog. I’ve dropped you a mail to discuss this further.

        Regards

        Athena

  • Jock says:

    Hi, This plug in is just what I’ve been looking for and up to now has worked brilliantly BUT when I try to display an image the widget converts the value of the custom field (which is the image URL) to the image ID! How can I get the widget to display the URL?

    There’s probably a really easy explanation but I’m stumped.

    Any ideas?

    • Jock,

      I’ve sent you an email asking for some more information and some sample data so I can try and recreate the problem on my development blog. The only thing I left out was if you could send me the HTML generated by the widget that would be good too.

      Regards

      Athena

  • David says:

    Hello, I’m trying to use your widget to display a view custom field values. It works as expected when i use it in the footer area but not when i use it in the sidebar. Any idea why?

  • Chris says:

    This plugin is exactly what I was looking for and it works great except for one issue– It works, but shows an error when used with the NextGEN Gallery plugin to show different image galleries in the sidebar for each post. The gallery shows and does work, but it also generates this error, “Parse error: syntax error, unexpected T_STRING in /wp-content/plugins/advanced-custom-field-widget/adv-custom-field-widget.php(566) : eval()’d code on line 2″.

    Any ideas?

  • Kevin says:

    Great plugin,

    Not sure if you can help but I cant work out if its possible to have more than 5 Additional Data Fields.
    I was hoping to have 8

    Any help would be great.

  • Hello, thanks for developing this plugin.
    I am building up a website to show an archive of old Journal articles (see current site http://www.obcjournal.org which is in drupal – we are moving over to WordPress).
    Your plug in looked useful for showing say a list of articles by the date of the issue they were in.
    I am using custom fields within a custom post though, so can I add something to the box below where it says “Primary Custom Field Key (required – Used for randomised content):” to show the custom field “issue_date” from the post-type “articles” so it displays?

  • Peter C. says:

    Hi,

    wonderful widget, very well done. Especially that it doesn’t display anything if it doesn’t fetch a valua. Thats perfect!

    After upgrading my blog from 3.3.1 to 3.5.1 this widget seems to break links up. The value I am trying to fetch is a URL. Using the PRETEXT and POSTTEXT fields I am trying to wrap that pdf URL into a link with around a nice little PDF icon.

    This worked so far, but now seems to break the link. It now wrongly shows the URL that was previously part of the pretext-html code. After that tit shows the closing quotation mark (but not the one before the url, strangly), than proceeds to display the icon. It really is rather strange.

    Error-wise interesting is what my browser shows for this broken link when I hover over it with my mouse. It shows the URL plus the beginning of the div-tag right like so: “bracket-DIV–CLASS-equals-quotationmark”

    I am using Atahualpa and can reproduce the error with Twenty Ten.

    Can you help?

    Your sincerely,
    Peter

  • Victoria says:

    Hello there! I found and implemented your plug in and I just love it! I built some custom fields and it did JUST WHAT YOU SAID IT WOULD. To make it easy on my authors, I have switched my custom fields to metaboxes using the jaredatch custom metaboxes plugin in from github. It pretty much packages the custom fields up and makes them clean. It also “hides the custom field from custom fields with an underscore” But now.. I don’t know what is considered the custom metabox “key” I tried using the metabox Name and ID (which has underscores) and neither works. Does ACFW work with those types of custom fields??? Or should I go back to the other way?

    • Victoria, I sent you an email last week about this. I’ve just downloaded the custom metabox plugin and will have a look at this issue later today.

      Regards

      Athena

Leave a Reply

 

Bad Behavior has blocked 326 access attempts in the last 7 days.

communication