WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Message display on linked posts from other sites pointing to main URL possible? (9 posts)

  1. gunlib
    Member
    Posted 8 years ago #

    Sorry if this topic's already been addressed here; I promise; I've searched and searched to no avail.

    I've noticed that sometimes when I click on a link in a blog pointing to a permalink on another blog, it takes me to the other blogger's post, but the post displays a message at the top saying something to the effect of:

    "This is not the homepage of the XYZ blog, you are reading one of our posts. Go HERE to visit our homepage."

    Does anybody know if there is a plugin or a hack available to do this in WordPress?

    Thanks in advance :-)

  2. niziol
    Member
    Posted 8 years ago #

    This may be a silly question: but have you checked to see if the text is there regardless of clicking on a link or manually going to the post?

  3. Kafkaesqui

    Posted 8 years ago #

    Something like the following added to your theme's header.php (or sidebar.php, or whatever as long as it's included on all pages) should take care of remote links to anything but the home page:

    <?php
    if(!is_home() && !empty($_SERVER['HTTP_REFERER']) && !strstr($_SERVER['HTTP_REFERER'], get_bloginfo('home')) ) :
    ?>
    <p>This is not the homepage of <?php bloginfo('name'); ?>, you are reading one of our posts. Go <a href="<?php bloginfo('home'); ?>">HERE</a> to visit our homepage.</p>
    <?php endif; ?>

  4. gunlib
    Member
    Posted 8 years ago #

    Kafkaesqui -

    Thanks for responding. I'll be the first to admit, I'm not the sharpest tool in the shed when it comes to mods. In fact, I'm almost sqeamish about even attempting them.

    Can you please suggest where would be a good place to cut and paste this code in the header.php to work the best? Remember; when you are responding... you are speaking to a newbie. I can find and edit the header.php, just afraid to screw it up, that's all.

    Thanks to both of you for responding :-)

  5. Kafkaesqui

    Posted 8 years ago #

    At this point the only answer I can provide is: Where do you want it to appear?

    Note that my suggestion for adding it to your header.php assumes some part of that template provides an area fit to display the text. If it doesn't, then we'd have to find a better place for it. For example, if you only want this appearing on single posts, somewhere in your theme's single.php would work just as well (if it has one; if not then index.php can be considered).

  6. gunlib
    Member
    Posted 8 years ago #

    "For example, if you only want this appearing on single posts, somewhere in your theme's single.php would work just as well (if it has one; if not then index.php can be considered)."

    Exactly. I am looking to display this on single posts which have been linked to by other bloggers, ONLY when they've been linked to by other bloggers. Possible? If so, what next?

    I truly appreciate your attempts to help, by the way :-) Thanx again...

  7. Kafkaesqui

    Posted 8 years ago #

    Like pulling teeth tonight. Anyway...

    You're using a slightly customized version of the Journalized Blue theme, which provides a limited range of places we can stick this. Does just above the date on a post sound good? Hope so, because that's where I'm helping you add it.

    In Journalized Blue's Main Index (index.php) template (accessed through the Theme Editor, or offline in a text editor), look for this line:

    <?php the_date('','<h2>','</h2>');?>

    This, obviously, is what outputs the date. So the "you're not on the home page" text doesn't get lost here, we'll duplicate the layout used by the_date() by sticking the text in an <h2> element instead of a <p>, as I have it from my last reply. In other more explanatory words, on a new line just above or before the one used by the_date(), insert the following:

    <?php if(!is_home() && !empty($_SERVER['HTTP_REFERER']) && !strstr($_SERVER['HTTP_REFERER'], get_bloginfo('home')) ) : ?>
    <h2>This is not the homepage of <?php bloginfo('name'); ?>, you are reading one of our posts. Go <a href="<?php bloginfo('home'); ?>">HERE</a> to visit our homepage.</h2>
    <?php endif; ?>

    Save and have fun.

  8. gunlib
    Member
    Posted 8 years ago #

    Absolutely freaking perfect and beautiful! That is exactly what it was I was hoping to accomplish :-)

    Thank you so very much for your help. Ya RAWK!

    Blog ON...

  9. gunlib
    Member
    Posted 8 years ago #

    Oh, and please consider this topic
    CLOSED :-)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.