[Resolved] Javascript will not load – Parsing Errors with GP

Home Forums Support [Resolved] Javascript will not load – Parsing Errors with GP

Home Forums Support Javascript will not load – Parsing Errors with GP

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #218695

    I’m using ACF successfully in other areas of the site – all showing up as expected on the front and back end.

    However in this new case, I am trying to trigger an accordion effect. I have created everything as usual, see the metaboxes on the page editor but upon loading the page, I get a big orange error message.

    I worked with a colleague (who is using a different parent theme) and she was able to successfully get it to work.

    I’m getting this error:

    Parse error: syntax error, unexpected '<' in /Users/jessicarosengard/Documents/Websites/jessicarosengard-new.dev/wp-content/plugins/gp-premium/hooks/functions/hooks.php(19) : eval()'d code on line 5

    Here’s my code:
    added to functions.php

    function wpb_adding_scripts() {
    	wp_register_script('myaccordion', get_template_directory_uri() . '/assets/js/myaccordion.js', array( 'jquery' ), '1.0', true );
    	  if ( is_page() ) {
    	add_action( 'wp_enqueue_scripts', 'wpb_adding_scripts' );

    Added to the hooks area (with Execute PHP checked)

    <div class="accordion">
    <?php if( have_rows('new_faq') ): 
    while ( have_rows('new_faq') ) : the_row();
    if( get_row_layout() == 'question_answer' ):
    <a href=""><h3><?php the_sub_field('my_question'); ?></h3></a>
    <?php the_sub_field('my_answer'); ?>
    <?php endif;
    else :
    // no layouts found

    Nothing is working and I’m not sure if there’s just a different way of doing this with GP. ๐Ÿ™

    Lead Developer
    Lead Developer

    Your PHP has an error in it.

    if( get_row_layout() == 'question_answer' ):

    Should be:

    if( get_row_layout() == 'question_answer' ): ?>

    BAAH. I will try that and see if it fixes things.
    (I genuinely hate using .js to do this and am looking to do a pure css method)

    Thanks! I hope this works!


    BINGO! Thank you. Worked!

    Any suggestions how to make the animation less jumpy? Each time I click an option, I do not see a smooth transition.


    Lead Developer
    Lead Developer

    It depends on the javascript.

    Why not use a shortcode like this?: https://wordpress.org/plugins/jquery-collapse-o-matic/


    A Shortcode plugin renders the ease-of-use for the client moot. This also ADDS another plugin which is unnecessary.

    The custom fields I created allow for easy “add/edit/save” for the client, since they will be managing changing content on this page. As you can see on the attached, it’s way too much for them to have to to manually deal with shortcodes (especially for for a client/person with absolutely no knowledge of things like this work or how easily it can break the layout of a page if a bracket is misplaced or accidentally deleted).

    I’d rather find a way to smooth the accordion opening/closing for the front end.

    Custom Fields with Accordion Expanding Boxes

    Lead Developer
    Lead Developer

    Ah I understand.

    I don’t really have any tips for accordion javascript etc.. but I know there’s tons of tutorials out there and quite a few ways to do it. Try a few until you find one you like ๐Ÿ™‚

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.