ACF shortcode in topic post frontend
-
Here is the ACF shortcode for a custom field. What bbPress template/file do I place this shortcode so that the custom field displays on the frontend of a topic post. Where do I place it.
[acf_views view-id=”60″ name=”Lake Point Marker 2″]
-
so is this the front end of any topic post, or a specific topic post ?
and exactly where do you want it?A link to a live example on your site, together with ‘under/over/beside xx’ would be useful.
I need this custom field in the front end of any topic post. I want it to show up underneath the bottom of the topic field.
Here is other code ACH generates. Not sure which one to use and what fle it is to be inserted into.
<div id=”view” class=”acf-view acf-view–id–57 acf-view–object-id–65″>
<div class=”acf-view__row acf-view__lake_marker_point”>
<div class=”acf-view__label”>Lake Marker Point</div>
<div class=”acf-view__field”>This is the marker location</div>
</div>
</div>One more possible code:
echo ‘Lake Marker: ‘ .get_field( ‘lake_marker_point’ );
<div class=”acf-view__row acf-view__lake_marker_point”>
<div class=”acf-view__label”>Lake Marker Point</div>
<div class=”acf-view__field”>This is the marker location</div>
</div>Note: where there is lake_marker_point in the coding above it is actually lake_marker_point_2.
I want it to show up underneath the bottom of the topic field.
ok, no idea what you mean by that, as asked can you provide a link and say precisely where you would like it
Back end
So I want the custom field to show up here on the Front-end:
FYI the following code displays the custom field in the Front-end on pages, page.php in the template.
echo ‘Lake Marker 2: ‘ .get_field( ‘lake_marker_point_2’ );
thanks, I’ll take a look tomorrow
just got 10 minutes to look at this.
try this
add_action ('bbp_theme_after_reply_content' , 'rew_display_acf') ; function rew_display_acf () { $id = bbp_get_reply_id() ; //if it is the topic... if (bbp_is_topic( $id ) { echo '<br>Lake Marker 2: ' .get_field( 'lake_marker_point_2' ) ; } }
or
add_action ('bbp_theme_after_reply_content' , 'rew_display_acf') ; function rew_display_acf () { $id = bbp_get_reply_id() ; //if it is the topic... if (bbp_is_topic( $id ) { echo '<br>Lake Marker 2: ' .get_field( 'lake_marker_point_2', $id ) ; } }
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
The code you gave me to insert into functions.php causes a fatal crash.
I found a code that works when inserted into …/wp-content/plugins/bbpress/templates/default/bbpress
<h6>Date: <?php the_field( ‘date’ ) ; ?></h6>
<h6>Fish Caught: <?php the_field( ‘fish_caught’ ) ; ?></h6>
<h6>Speed: <?php the_field( ‘speed’ ) ; ?></h6>But it only displays if put in certain areas. Here is the closet area it displays to the topic content.
<?php bbp_single_topic_description(); ?>
<h6>Date: <?php the_field( ‘date’ ) ; ?></h6>
<h6>Fish Caught: <?php the_field( ‘fish_caught’ ) ; ?></h6>
<h6>Speed: <?php the_field( ‘speed’ ) ; ?></h6>
<h6>Water Features: <?php the_field( ‘water_features’ ) ; ?></h6>
<h6>Lure & Color: <?php the_field( ‘lure_color’ ) ; ?></h6><?php if ( bbp_show_lead_topic() ) : ?>
<?php bbp_get_template_part( ‘content’, ‘single-topic-lead’ ); ?>
I have tried putting it below either of these items and it will not dislay in the frontend.
<?php if ( bbp_show_lead_topic() ) : ?>
<?php bbp_get_template_part( ‘content’, ‘single-topic-lead’ ); ?
From what I can tell the code actually needs to be inserted in the single-topic-lead. I have tired inserting it everywhere within the single-topic-lead.php page but no matter where I put it, it does not show up. Here is where I think it needs to go:
<?php bbp_topic_author_link( array( ‘show_role’ => true ) ); ?>
<?php if ( current_user_can( ‘moderate’, bbp_get_reply_id() ) ) : ?>
<?php do_action( ‘bbp_theme_before_topic_author_admin_details’ ); ?>
<div class=”bbp-topic-ip”><?php bbp_author_ip( bbp_get_topic_id() ); ?></div>
<?php do_action( ‘bbp_theme_after_topic_author_admin_details’ ); ?>
<?php endif; ?>
<?php do_action( ‘bbp_theme_after_topic_author_details’ ); ?>
</div><!– .bbp-topic-author –>
<div class=”bbp-topic-content”>
<?php do_action( ‘bbp_theme_before_topic_content’ ); ?>
<?php bbp_topic_content(); ?>
<h6>Date: <?php the_field( ‘date’ ) ; ?></h6>
<h6>Fish Caught: <?php the_field( ‘fish_caught’ ) ; ?></h6>
<h6>Speed: <?php the_field( ‘speed’ ) ; ?></h6>
<h6>Water Features: <?php the_field( ‘water_features’ ) ; ?></h6>
<h6>Lure & Color: <?php the_field( ‘lure_color’ ) ; ?></h6>
<?php do_action( ‘bbp_theme_after_topic_content’ ); ?>
</div><!– .bbp-topic-content –>
</div><!– #post-<?php bbp_topic_id(); ?> –>NOTE: What is strange is that if I delete the content-single-topic-lead.php file to make sure the page is not cached, it does not break the topic post which makes no sense to me.
Here is the actual topics page:https://thedoverfamily.com/gfwc/forums/topic/last-try/
- You must be logged in to reply to this topic.