0

here's what i'm trying to achieve!

HTML:

some text
<!--more-->
some text

when post is loaded:

some text
MY TEXT WHICH WAS ADDED TO THE MORE TAG
some text

on my old WP site, i used this to have a banner displayed on posts exactly where the tag was inserted.

unfortunately, i can't get this to work in Genesis.

here's the code which was added to functions.php on my old website:

function adsense_added_at_more_tag($text) {
if( is_single() ) :
$ads_text = 'BANNER GOES HERE';
$pos1 = strpos($text, '<span id="more-');
$pos2 = strpos($text, '</span>', $pos1);
$text1 = substr($text, 0, $pos2);
$text2 = substr($text, $pos2);
$text = $text1 . $ads_text . $text2;
endif;
return $text;
}

any ideas on how to get this to work in Genesis?

i got some great tips from Brad who suggested the following code:

add_filter( 'the_content_more_link', 'read_more_link' );
function read_more_link() {
if ( is_single() ) {
echo '<div class="your-banner">Add Your Banner HTML Here</div>';
    }
}

i've tried adding this to functions.php in Genesis, but nothing happens. the "Add Your Banner HTML Here" text doesn't appear in the post.

i've explored various code examples online and tried tweaking the code pasted above with my (it's safe to say) non-existant PHP skills without success.

can anyone figure out how to modify the code to show text in a single post in Genesis?

0

You can hook in the banner using the the_content_more_link filter by modifying this code.

add_filter( 'the_content_more_link', 'sp_read_more_link' );
function sp_read_more_link() {
return '<a class="your-banner" href="' . get_permalink() . '">[Banner Shortcode]</a>';
}

Another option would be to create a shortcode for your banner, and add the shortcode to the the_content_more_link filter above.

Or you could simply echo the div class and/or HTML for the banner in a custom function with or without a conditional tag.

add_filter( 'the_content_more_link', 'read_more_link' );
function read_more_link() {
if ( is_single() ) {
echo '<div class="your-banner">Add Your Banner HTML Here</div>';
    }
}

Either add HTML for your banner or create a shortcode otherwise the code does nothing.

  • thank you so much for the tips! i'm a total beginner when it comes to php, so i'll need some time to figure out how to implement this. hopefully i'll get this to work today. one thing, though. in the line ( has_tag(tagname) ) i should replace 'tagname' with the corresponding ID for the more tag in Genesis? – kkin Jan 29 '14 at 15:11
  • No. I removed that and changed the answer as i initially thought you wanted to hook the banner in from the post meta footer. I now realize you want to use the more tag. – Brad Dalton Jan 29 '14 at 15:18
  • thanks again! i've tried using these two in functions.php but nothing happens on the site. i can't figure out how to display the actual banner (or whatever i input in the banner field). – kkin Jan 29 '14 at 16:06
  • What exact code did you paste into your theme and where did you paste it? These are examples of what can be done and have NOT been tested on your specific theme. You will need to modify the code and add your shortcode or class and HTML for banner image. – Brad Dalton Jan 29 '14 at 16:12
  • i've tried using both variants in functions.php, but there is no output in either case. the HTML part is no problem, but i can't figure out how to modify your two examples to output anything. incoming newbie question: should i add some code to the examples posted above in order for them to output the actual banner code / link? if it helps, the theme is Magazine Pro for Genesis, but i don't think it should make much difference because it's a Genesis child theme. anyways, thank you SO MUCH for taking the time to help! – kkin Jan 29 '14 at 16:21
0

ok, here's the solution:

Text after more tag in posts

tested and working in Genesis!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.