Forums

[Plugin: NextGEN Custom Fields] Custom field in widget (4 posts)

  1. Chanty87
    Member
    Posted 1 month ago #

    Hello!

    I'm glad I found this excellent plugin, it suits my needs perfectly for my portfolio! I have just one question though: I have placed the Display Recent Images widget in my footer and I want to display the content of one of my custom fields (in this case the date) below the images. How do I achieve this? Placing

    '. $image->ngg_custom_fields['Date'] .'

    in the output of widgets.php doesn't work, unfortunately, nothing shows up.

    Thanks in advance :)

    http://wordpress.org/extend/plugins/nextgen-gallery-custom-fields/

  2. shauno
    Member
    Posted 1 month ago #

    Hi

    The widgets don't call call a hook for the custom fields to get loaded into memory like the normal galleries. This isn't a problem though, as there is a nice way to still get the field.

    You can call the function nggcf_get_field($image->pid, "Field Name Here"); where you want to display the custom field. This call obviously needs to be made inside the foreach loop starting on line 403, and ending on line 426 of widgets.php

    I'm not sure what level your PHP is, but you will need to output the results of that function call into the $out variable.

    So, for instance, if you want the text inside the a tag, you you could add
    $out .= nggcf_get_field($image->pid, "test field");
    to line 418 of widgets.php (I am assuming NGG 1.3.6 for line numbers).

    Let me know if you need any more help.

  3. Chanty87
    Member
    Posted 1 month ago #

    Yes, I figured :) My PHP knowledge is pretty basic as of yet but I think I can get it to work now thanks to you :) And if not I'll just let you know. Thanks!

  4. Chanty87
    Member
    Posted 1 month ago #

    It worked! Thanks :D

Reply

You must log in to post.

About this Topic