Support

Account

Home Forums General Issues Getting ACF to work with Pagelines DMS

Solved

Getting ACF to work with Pagelines DMS

    • bfrye26

    • September 5, 2013 at 6:30 am

    Hello,

    I am trying to get ACF fields to display in DMS from pagelines. I have tried a widget method with no luck and now am trying to get it working with hooks.

    No matter what I do I can not get the fields to display properly

    Am I missing something?

    I have tried this code in the sidebar widget:

    <?php the_field(“editor_score”); ?>

    and have tried this with hooks:

    add_action(‘action_name’, ‘review_details’);
    function review_details() { ?>
    the_field( “editor_score” );
    <?php
    }

    I am open to ideas

    • Elliot

    • September 5, 2013 at 12:38 pm

    Hi @bfrye26

    I am unfamiliar with the ‘DMS’ you refer to, however, I’m guessing it is a theme.

    The issue will most likely be related to the fact that when you use the the_field function, ACF doesn’t know what post to load the data form.

    You need to use the_field WITHIN the WP loop, just like the_title or the_content.

    Does this help?

    Thanks
    E

    • bfrye26

    • September 5, 2013 at 12:57 pm

    The issue is it is not easy to add the code inside the loop. Since it uses sections you place to load the loop etc it can not be added as easy as seen either other themes.

    They suggested using hooks to get it to work although these did not seem to give the desired output either.

    Is there a way to use it with a widget or something?

    • Elliot

    • September 5, 2013 at 1:10 pm

    Hi @bfrye26

    ACF needs 2 things, the field name and the post ID to load from.

    If you can get those 2 varibles, then you can load data with the get_field.

    You need to do some debugging to find those values.

    Field_name is the easy one, but getting the post_id may be an issue if not able to do it within the loop. There is always global $post? Try that

    Cheers
    E

    • bfrye26

    • September 5, 2013 at 1:41 pm

    I managed to get it to show with this code in a widget:

    <?php
    $custom_field = get_post_custom_values(‘editor_score’);
    if(!empty($custom_field)){
    echo ‘<div class=”result-extra”>’;
    echo __(‘Editor Score: ‘).”.$custom_field[0];
    echo ‘</div>’;
    }

    ?>

    Only issue is if there are two entries in the fields it displays info like this:

    a:3:{i:0;i:15;i:1;i:172;i:2;i:105;}

    you can see this on: http://www.cgmagazine.ca/wordpress/game_review/saints-row-iv.html

    • bfrye26

    • September 6, 2013 at 2:19 am

    Okay, after some work I have managed to get it calling the needed aspects

    now the question is:

    How can I get it to display taxonomies rather then then just outputting the code the database uses and how can I stop it from listing any array field as just the word Array.

    Here is my code so far:

    <?php
    global $post;
    $postid = $post->ID;
    $systemon = get_field(“played_on”, $postid);
    $score = get_post_meta($postid, ‘editor_score’, true);
    echo ‘<div class=”system”>’;
    echo __(‘Payed On: ‘).’ ‘.$systemon;
    echo ‘</div>’;
    echo ‘<div class=”editorscore”>’;
    echo __(‘Editor Score: ‘,’taxonomies-filter-widget’).’ ‘.$score;
    echo ‘</div>’;
    ?>

    • bfrye26

    • September 6, 2013 at 3:12 am

    Here is the code that is as far as I could get. Still unable to display the custom taxonomies in the side
    <?php
    global $post;
    $postid = $post->ID;
    $systemon = get_field(“played_on”, $postid);
    $genres = get_field(“genres”, $postid);
    $esrb = get_field(“esrb”, $postid);
    $publishers = get_field(“publishers”, $postid);
    $developer = get_field(“developer”, $postid);
    $players = get_field(“players”, $postid);
    $release_date = get_field(“release_date”, $postid);
    $price = get_field(“price”, $postid);
    $score = get_post_meta($postid, ‘editor_score’, true);

    echo ‘<div class=”system”>’;
    echo __(‘Payed On: ‘).’ ‘.$systemon[0];
    echo ‘</div>’;
    echo ‘<div class=”system”>’;
    echo __(‘Systems: ‘,’taxonomies-filter-widget’).’ ‘.$term->name;
    echo ‘</div>’;
    echo ‘<div class=”genre”>’;
    echo __(‘Genre: ‘,’taxonomies-filter-widget’).’ ‘.$genres;
    echo ‘</div>’;
    echo ‘<div class=”esrb”>’;
    echo __(‘ESRB: ‘,’taxonomies-filter-widget’).’ ‘.$esrb;
    echo ‘</div>’;
    echo ‘<div class=”publishers”>’;
    echo __(‘Publisher: ‘,’taxonomies-filter-widget’).’ ‘.$publishers;
    echo ‘</div>’;
    echo ‘<div class=”developers”>’;
    echo __(‘Developer: ‘,’taxonomies-filter-widget’).’ ‘.$developer;
    echo ‘</div>’;
    echo ‘<div class=”players”>’;
    echo __(‘Players: ‘,’taxonomies-filter-widget’).’ ‘.$players;
    echo ‘</div>’;
    echo ‘<div class=”editorscore”>’;
    echo __(‘Editor Score: ‘,’taxonomies-filter-widget’).’ ‘.$score;
    echo ‘</div>’;

    ?>

    • Elliot

    • September 8, 2013 at 6:19 pm

    Hi @bfrye26

    Can you point out the ‘taxonomies’ line of code which isn’t working?
    What have you tried. Do you understand the data which is being returned. Have you tried to look through the array and load / display the HTML you wish?

    Thanks
    E

    • pokazhi

    • September 19, 2013 at 1:17 am

    I have a similar issue.

    Only file with “loop” that i found in DMS theme files is /postloop/section.php

    But the insertion of code
    echo '<p>' . get_field('field_name') . '</p>';

    affects the categories in which there is a record and the record itself..
    And i see content of custom field in category under list of posts and under main content.

    • pokazhi

    • September 19, 2013 at 1:22 am

    Hello!

    I solve my problem with ACF & DMS.

    I have installed Pagelines Customize plugin and add filter to
    plugins/pagelines-customize/functions.php file.

    You can take plugin download link there (pagelines support forum):
    http://forum.pagelines.com/topic/29473-cant-find-the-pagelines-customize-plugin/?hl=pagelines+customiz

    The code that work for me:`add_filter( 'the_content', 'add_acf' );
    function add_acf( $content ){
    if( ! is_single() ) // if were not on a post/page just return the content.
    return $content;
    $label1 = get_field_object('soc-dosl'); //set label of the field
    $field_1 = '<p>' . '<div class=”dop-dani”>' . $label1['label'] . ': </div>' . get_field('soc-dosl') . '</p>'; // set content of string – label plus field plus markup.
    return $content . $field_1; //Show result of concatenation of content with field label and field content
    }
    `

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.