Home › Forums › Front-end Issues › Displaying a group outside WordPress Loop › Reply To: Displaying a group outside WordPress Loop
James, The Tab is working using Ajax. Here is my page template that is set for tabs.
<?php
Template Name: Single Post with data
*/
//* Enqueue tab js including jQuery UI Tabs
add_action( 'wp_enqueue_scripts', 'my_load_tab_script' );
function my_load_tab_script() {
wp_enqueue_script( 'my-tabs', get_stylesheet_directory_uri() . '/assets/js/my-tabs-ajax.js', array( 'jquery-ui-tabs' ), '1.0.0', true );
}
//* Remove the post content and add our tabbed content
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
add_action( 'genesis_entry_content', 'my_do_tabbed_content' );
function my_do_tabbed_content() {
?>
<div id="tab-wrap">
<!-- Tab links -->
<ul class="tabs">
<li><a href="#tab_1">Overview</a></li>
<li><a href="<?php echo get_stylesheet_directory_uri(); ?>/includes/tabs/data.php" class="tab">HTML</a></li>
</ul>
<div class="my-tab-content">
<!-- Tab content - id must match the href from the tab link -->
<div id="tab_1">
<?php the_content(); ?>
</div>
</div>
</div>
<?php
}
//* Run the Genesis loop
genesis();
and here is my data tab file data.php
<?php
// Include WordPress
define('WP_USE_THEMES', false);
require_once('../../../../../wp-load.php');
$group_ID = 12113;
$fields = get_fields($groupID);
$fields = get_field_objects();
echo '<div class="aps-column">';
echo '<div class="aps-group">';
echo '<ul class="aps-specs-list">';
if( $fields )
{
foreach( $fields as $field_name => $field )
{
if( $field['value'] )
{
echo ' <li>';
echo '<strong class="aps-term">' . $field['label'] . '</strong>';
echo '<div class="aps-attr-value"><span class="aps-1co">' . $field['value'] . '</span></div>';
echo '</li>';
}
}
}
echo '</ul>';
echo '</div>';
echo '</div>';
?>
I tried a lot of code but as i am not a php professional i am doing some mistake. Thanks again for your kind support.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.