Site logo

Archived topic

Problem with moving from Legacy Hooks to Elements

16 replies · Started by Edin on November 19, 2018

Viewing posts 1–15 of 17

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

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

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

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

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; ?>

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

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).

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

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

Ok, I experimented a little, when I remove:

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

it works.

Where's the problem?

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;
}

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

Thank you!

If you want to avoid !important, try this:

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

Glad I could help! :)

Thanks again, Tom.

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

It's best practice to avoid it where possible :)

This archived topic is closed to new replies.