Support

Home Forums Event Espresso Premium ACF — espresso_events not a post type

ACF — espresso_events not a post type

Posted: February 2, 2020 at 1:45 pm

Viewing 11 reply threads


Maureen

February 2, 2020 at 1:45 pm

Have followed the instructions from https://eventespresso.com/wiki/add-sponsors-section-events-using-advanced-custom-fields/ to add a sponsors section. The section shows up on the back end, but sponsors never show up on the front end. The location settings on CFP does not include espresso_events, which I suspect is the problem.

EE 4.10.3
Advanced Custom Fields PRO, 5.8.7 (came with the theme, Pro by Theme.co, 3.0.4)
WP 5.2.5

A post from 2016 https://eventespresso.com/topic/acf-cannot-select-event-post-type/
referencing EE 4.9.23 and ACF Pro 5.5.2 with the same problem. Three years later, is this still a bug with ACF Pro, or is there something I can do to make this feature work for me?


Josh

  • Support Staff

February 3, 2020 at 9:14 am

Hi Maureen,

I suspect it’s a different problem. You do see the section on the event edit page, correct? The sponsors not showing on the front end would be an indication there’s a problem with the code you added. May I ask did you add the code to your theme’s functions.php file or was it added to its own plugin?


Maureen

February 3, 2020 at 9:21 am

That glimmer of hope makes me very happy!

The code was added to a plugin.


Maureen

February 3, 2020 at 9:23 am

Yes, the section appears on the back end. I can add content, but nothing shows up on the event page.


Maureen

February 3, 2020 at 9:30 am

<?php
/*
Plugin Name: Events Espresso NAIOP Customizations
Description: Events Espresso NAIOP Customizations
*/
/* Begin Adding Functions Below This Line; Do not include an opening PHP tag as this sample code already includes one! */

function ee_event_sponsor_area() {
    if( have_rows('sponsors') ): ?>
        <div class="sponsor-box">
            <h3 class="sponsor-header">Event Sponsor</h3>
        <?php while ( have_rows('sponsors') ) : the_row(); ?>
            <div class="the-sponsor clearfix">
                <div class="the-sponsor-image"><a>"><img />"></a></div>
                <h3 class="the-sponsor-company"><?php the_sub_field('company');?></h3>
                <div class="the-sponsor-bio"><?php the_sub_field('bio');?></div>
                <div class="the-sponsor-link"><a target="_blank" rel="noopener noreferrer">">View Sponsor</a></div>
            </div>
        <?php endwhile; ?>
        </div>
    <?php else:
    endif;
}
add_action( 'AHEE_event_details_after_the_content', 'ee_event_sponsor_area' );

/* Stop Adding Functions */
  • This reply was modified 4 years, 8 months ago by Josh. Reason: fix code formatting


Josh

  • Support Staff

February 3, 2020 at 9:51 am

The code you have differs quite a bit from the tutorial. You’ll note that the tutorial doesn’t make use of ACF’s have_rows() function.

I can help you with troubleshooting the EE side of this. You could try adding this temporary debug code to see if the EE provide hook is firing:

add_action( 'AHEE_event_details_after_the_content', 'ee_example_output' );
function ee_example_output() {
echo '<h3>The hook AHEE_event_details_after_the_content fires here</h3>';
}

Then double check to make sure the plugin is activated. After that you should see the example output on the site event page


Maureen

February 3, 2020 at 11:13 am

I had a developer helping with the setup, and the idea was to have the ability for multiple sponsors per event, hence the repeater code. The developer is gone, and here I am, learning as I go.

I started over using your tutorials and have the sponsor area showing up. However, the logo is showing up as a broken link.


Josh

  • Support Staff

February 3, 2020 at 1:44 pm

Hi,

It looks like you need to change this:

<div class="the-sponsor-image"><a>"><img />"></a></div>
to something like:

<div class="the-sponsor-image"><?php if( get_field('sponsor_logo_image') ): ?>
    <img src="<?php the_field('sponsor_logo_image'); ?>" />
<?php endif; ?></div>

You’ll find more information here:

https://www.advancedcustomfields.com/resources/image/
and
https://www.advancedcustomfields.com/resources/code-examples/#working-with%20images%20%E2%80%93%20id


Maureen

February 5, 2020 at 2:43 pm

I’m using the code straight out of the sample, so I don’t have <div class=”the-sponsor-image”>“>“></div> in the code to replace.


Josh

  • Support Staff

February 5, 2020 at 3:08 pm

The code from the sample has this:

<h4><img align="right" src="<?php the_field( "sponsor_logo_image" )?>"><strong><a href="<?php the_field( "sponsor_website" )?>"><?php the_field( "sponsor_company" )?></a></strong></h4>

The code you shared in your earlier reply has this:

<div class="the-sponsor-image"><a>"><img />"></a></div>

Maybe you’ve change the code since then.

In any case, to show an image using a custom field image url, you’ll use the html
<img> tag and use the src attribute.

like this:

<div class="the-sponsor-image"><?php if( get_field('sponsor_logo_image') ): ?>
    <img src="<?php the_field('sponsor_logo_image'); ?>" />
<?php endif; ?></div>

If the above doesn’t show an image, you could double check your field slug to make sure it matches the field in the code.


Maureen

February 7, 2020 at 9:01 am

I have scrapped my original code (for now) and am using the EE sample code, straight up.

function ee_event_sponsor_area() {
?>
<div class=”sponsordetails”>
<h3><span class=”dashicons dashicons-heart “></span>Event Sponsor</h3>

<h4>“>“><?php the_field( “sponsor_company” )?></h4>
<?php the_field( “sponsor_bio” )?>
</div>
<?php
}
add_action( ‘AHEE_event_details_after_the_content’, ‘ee_event_sponsor_area’ );

The sponsor section show up, but the image is a broken link. I can put an image in the bio wysiwyg field, but the sponsor_logo_image is a broken link.


Josh

  • Support Staff

February 7, 2020 at 12:53 pm

Hi,

I’m afraid I do not see an image tag (or <img>) in the code in your above reply. Maybe the forum software ate it though.

In the future please consider putting the code into a bin at wpbin.io then share a link here.

If you want to add an image, the following code can be added to your function:

<div class="the-sponsor-image"><?php if( get_field('your_field_slug_for_the_image') ): ?>
    <img src="<?php the_field('your_field_slug_for_the_image'); ?>" />
<?php endif; ?></div>
Viewing 11 reply threads

The support post ‘ACF — espresso_events not a post type’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso