Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter sn4th4n

    (@sn4th4n)

    I’m able to get that to work on a single product detail page by modifying product-single.php with the following after adding the custom field “product_subtitle”

    <div id="product_subtitle"><?php if( get_field('product_subtitle') ) { the_field('product_subtitle'); } ?></div>

    I’m having trouble with getting it to work on the page with multiple products. I’m using a custom page with the shortcode method, so WordPress is using page.php and it’s all coming through

    <?php the_content(); ?>

    I think this is where I’d need to use the hook. I’ve tried stuff like putting this within page.php

     <?php 
    if( get_field('product_subtitle') ) { $mySub = the_field('product_subtitle'); }		
                                        
    echo "<script>wp.hooks.addFilter('after.product.title', 'wpshopify', function (defaultVal, productData) {return \"<div id='product_subtitle'>".$mySub."</div>\"});</script>"
    ?>

    If I substitute a string for $mySub it works fine, putting the same subtitle under each title on the page, but assigning $mySub to a custom field comes up as a blank div because ‘the_field’ I think needs an id as an argument.

    I can’t understand how to affect all the instances on the page. I’m not sure if I’m going about this the right way – possibly I need a “while” statement to affect each instance individually? Sorry, my coding ability is a bit limited. I hope you will be able to help.

    Thread Starter sn4th4n

    (@sn4th4n)

    Nice, that works, both of those.

    -I was thinking the “create product detail pages” switch would do it, but that seems to not have any effect, as I did have product detail pages and it was off. Turning that switch on seems to change nothing.

    But your answer does work. Thank you.

    I was getting the same error on the WordPress dashboard page and it was causing my main menu to not show up on the site every other load or so. I think I’ve solved the problem by changing the “continue;” on line 326 of “ba.settings.page.class.php” to “break;”. I think it has to do with a change in php version 7.3 which is somewhat documented here: https://www.php.net/manual/en/migration73.incompatible.php

    It seems to work – I’m not sure if it may have broken some other functionality.

Viewing 3 replies - 1 through 3 (of 3 total)