• This is a bizarre question, I know… but I wanted to know if I could possibly grab the more link (i.e. the_content('read more');) as a variable to see if it’s being applied?

    basically I need to put the link in a weird spot that isn’t customizable via CSS (which is how I normally do it). Instead of at the end of the post content, I need it to be in the post meta section. Right now, I basically used $strip_teaser to make it invisible at the end of the post, and hard-coded a read more link in the post meta. However, now the link shows up on ALL posts – whether <–more–> is used or not. SO I was wondering if there was a way to grab it as some kind of variable and either echo it out in a new spot, or check to see if <!–more–> was used and if so, have the link display.

    I know I could probably do this with a filter, but I was hoping for a cleaner (and faster) method?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Could you use a combination of get_the_content and strpos to check for a class="more-link"?

    Thread Starter Doodlebee

    (@doodlebee)

    Yeah, that *is* what I ended up doing, but for some reason, it’s not taking. I’m troubleshooting more (there’s got to be some odd reason as to why – maybe a good night’s sleep has helped and I’ll see it), but i was hoping for something a little simpler than that. Oh well, whatever works I guess 😉 If I figure out why my code isn’t taking, I’ll post the solution.

    Thanks! 🙂

    esmi had it right. I had to do this same thing for a theme to display a custom thumbnail only for posts which used “<!–more–>” and the code I used was :

    <?php if(strpos(get_the_content(),'class="more-link"') !== false) : ?><img src="<?php $key="thumbnail"; echo get_post_meta($post->ID, $key, true); ?>" alt="thumbnail" class="thumbnail" /><?php endif; ?>

    Worked out perfectly. Thanks, esmi.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘grab more link as variable?’ is closed to new replies.