Site logo

[Resolved] Problem with moving from Legacy Hooks to Elements

Home Forums Support [Resolved] Problem with moving from Legacy Hooks to Elements

Home Forums Support Problem with moving from Legacy Hooks to Elements

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #730734
    Edin

    Hello,

    I’ve successfully moved all the hooks, except this one that just doesn’t want to work:

    Old Legacy Hook:

    screen1

    New Elements Hook:

    screen2

    Display Rules:

    Any idea why it won’t work?

    Thanks,
    Eddie

    #730863
    David
    Staff
    Customer Support

    Hi there,

    does it not render anything?
    Also note that you have a shortcode within the PHP – what happens if you check the execute shortcode as well

    #732220
    Edin

    I’ve just tested again with execute shortcode enabled, and it comes up empty again.

    #732315
    David
    Staff
    Customer Support

    Any chance you can copy and paste the exact code you are using here?

    #732336
    Edin

    Sure.

    New Elements:

    <div class="entry-meta">by <?php the_author(); ?>, <?php echo do_shortcode( '[est_time]' ); ?> read, <?php comments_number( 'no responses', 'one response', '% responses' ); ?>, updated on <span class="date updated published"><time datetime="<?php the_modified_time('Y-m-d'); ?>" itemprop="dateModified"><?php the_modified_time('M jS, Y'); ?></time></span></div>

    Old GP Hooks:

    <?php if ( is_single() ) : ?><div class="entry-meta">by <?php the_author(); ?>, <?php echo do_shortcode( '[est_time]' ); ?> read, <?php comments_number( 'no responses', 'one response', '% responses' ); ?>, updated on <span class="date updated published"><time datetime="<?php the_modified_time('Y-m-d'); ?>" itemprop="dateModified"><?php the_modified_time('M jS, Y'); ?></time></span></div><?php endif; ?>

    #732369
    David
    Staff
    Customer Support

    Do you still have the Legacy Hook with that code in it? If so can you delete and make sure to empty the trash.

    #732379
    Edin

    No, before testing it, I‘ve disabled and saved the legacy hook (that’s how I did it with the migration of all other hooks).

    #732389
    Tom
    Lead Developer
    Lead Developer

    What happens if you add a random word like “Test” after your new hook content? Does it appear on the page at all?

    #732421
    Edin

    Yes, “Test” appears exactly where it should be when added at the end.

    #732425
    Edin

    Ok, I experimented a little, when I remove:

    <div class="entry-meta"></div>

    it works.

    Where’s the problem?

    #732447
    Tom
    Lead Developer
    Lead Developer

    Ah, the theme is probably set to remove the post meta, which adds CSS to hide that element.

    Try adding this:

    .entry-meta {
        display: block;
    }
    #732466
    Edin

    Perfect Tom, it worked (I had to add a !important though).

    Thank you!

    #732735
    Tom
    Lead Developer
    Lead Developer

    If you want to avoid !important, try this:

    .entry-content .entry-meta {
        display: block;
    }

    Glad I could help! 🙂

    #733006
    Edin

    Thanks again, Tom.

    Just a quick question, is it recommendable to avoid !important? I’m using it all over the place…

    #733574
    Tom
    Lead Developer
    Lead Developer

    It’s best practice to avoid it where possible 🙂

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