Viewing 2 replies - 1 through 2 (of 2 total)
  • I also need to know how to do this – I’m using Advanced Custom Fields to store a bunch of data related to a post and need to display some of those fields (these are basically custom fields) in my wish list.

    Would it be possible to add something like this?

    ##postCustomFieldName##

    Where ‘CustomFieldName’ returns the get_post_meta()?

    Thanks for this great plugin by the way!

    Osu

    Hey there,

    I found the answer (at least when using normal custom fields or, in my case, Advanced Custom Fields).

    If you want to include custom fields, you need to modify the plugin file gd-mylist-code.php so that you can add your own ##tagName# for use in the plugins templates.

    I’ll try to explain so it’s understandable for someone else seeing this – instructions below on what to do.

    ——————————————————-
    File: gd-mylist/gd-mylist-code.php

    In the foreach ($posts as $post) loop, create variables for your custom fields (my example uses a soundcloud and gumroad link):

    $postACF_sc =  get_post_meta($postId, 'sc_link', true); // Get soundcloud link
    $postACF_gumroad =  get_post_meta($postId, 'gumroad_url', true); // Get Gumroad link

    Then, add your own str_replace() functions below the line that says $html = file_get_contents($templates_html['box_list'].$locale);

    i.e:

    $html = str_replace('##postACF_sc##', $postACF_sc, $html);
    $html = str_replace('##postACF_gr##', $postACF_gumroad, $html);

    This will let you use ##postACF_sc## and ##postACF_gr## in the plugin’s template files to show your custom fields.

    File: gd-mylist/template/box-list.php

    I just chose this template file as an example, but you can add your new made tags to the HTML markup here to display them i.e.

    <article class="gd-mylist-box audio-item">
    	##postBtn##
    	<h2>##postTitle##</h2>
    	<a href="##postACF_sc##" class="sc-player audio-item--url">##postTitle## on SoundCloud</a>
    	<a href="##postACF_gr##" class="audio-item--buy btn btn-green" data-product-url="##postACF_gr##">Buy</a>
    	<a href="##postUrl##" class="view-track btn btn-blue">View track</a>
    </article>

    ——————————————————-

    That’s what is working for me, although I’m working through a different problem now!

    Cheers,

    Osu

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Post type field’ is closed to new replies.