Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

How to add Linked ➚ link on selected post to Neutrica+ WordPress

  • SOLVED

Ok [[LINK href="http://wpquestions.com/question/show/id/1065"]]From this Post[[/LINK]] the solution was done perfectly last night and that code successfully added a post meta field to with the outgoing link list url via this output - Linked ➚ you can see on it on this [[LINK href="http://www.jorgeledesma.net/thoughts-on-the-mac-book-air-13/"]]post[[/LINK]]

Now I want to add the same link but at the end of each post that has the custom field Linked_list_url.

So it will look something like this

Title
Body
<br />
<blockquote>Jump to this <strong>Linked ➚</strong></blockquote>

Answers (3)

2010-10-29

enodekciw answers:

open up your single.php
find line like this:
<div class="entry-content"><?php the_content(); ?></div>
Just after that line add this code:

<?php $my_link = get_post_meta(get_the_ID(), 'linked_list_url', true); ?>
<?php if($my_link != '') : ?>
<br/><span class="meta-utility">Jump to this <a href="<?php echo $my_link;?>">linked &#x279a;</a></span>
<?php endif; ?>


If it won't work, paste your single.php (or any other template file, where you wanna use this snippet) here and I will do it for you ;)

Btw, you still gonna need to give that span some other class if you want to look it somehow different ;)


enodekciw comments:

oh, it looks like that you already have $my_link defined in that template file so just change above code to something like this


<?php if($my_link != '') : ?>
<br/><span class="meta-utility">Jump to this <a href="<?php echo $my_link;?>">linked &#x279a;</a></span>
<?php endif; ?>


Because if you already got that custom field value above the post and you don't need to get it again. So no need to call get_post_meta() function again.


Jorge Ledesma comments:

Ok, from the previous post, let me explain. I use the theme framework [[LINK href="http://themeshaper.com/"]]Thematic[[/LINK]] which is free and open source and a premium child theme called N[[LINK href="http://www.fthrwght.com/neuticaplus/"]]eutrica+[[/LINK]]

And Maor who solved and earned my previous question worked with the functions.php of Neutrica+ because since this is a framework it does not have a single.php, index.php files its all on either the Thematic functions.php or the Neutrica+ function.php(which I attached originally with this question)

Now Thematic holds their entire single.php, index.php and so forth in a single php file called content-extensions.php.

I can upload all these upon as well. Remember, the function is already which works perfectly is called to the post meta field of my post on what goes into the single.php or " is single" portion of the functions.php

My goal is to have that link output as on the post that have it after the post content like so

Title
Body<br />
Jump to this Link ➚

and perhaps wrap in these tags<h6></h6> but I can always play with these myself to see which one looks nicer


enodekciw comments:

ah, got few beers tonight, my bad. Ok, lets do it like this:

1) open up your functions.php (the one you gave to Maor)
2) find these lines:
// Creates the post content
function childtheme_override_content() {
global $thematic_content_length;

if ( strtolower($thematic_content_length) == 'full' ) {
$post = get_the_content(more_text());
$post = apply_filters('the_content', $post);
$post = str_replace(']]>', ']]&gt;', $post);
} elseif ( strtolower($thematic_content_length) == 'excerpt') {
$post = '';
$post .= get_the_excerpt();
$post = apply_filters('the_excerpt',$post);
} elseif ( strtolower($thematic_content_length) == 'none') {
} else {
$post = get_the_content(more_text());
$post = apply_filters('the_content', $post);
$post = str_replace(']]>', ']]&gt;', $post);
}
echo apply_filters('thematic_post', $post);
} // end content

3. replace them with these lines:
// Creates the post content
function childtheme_override_content() {
global $thematic_content_length;

$linked = get_post_meta(get_the_ID(), 'linked_list_url', true);
$belowcontent = '<br/><span class="meta-utility">Jump to this <a href="' . $linked . '">linked &#x279a;</a></span>';

if ( strtolower($thematic_content_length) == 'full' ) {
$post = get_the_content(more_text());
$post = apply_filters('the_content', $post);
$post = str_replace(']]>', ']]&gt;', $post);
$post .= $belowcontent;
} elseif ( strtolower($thematic_content_length) == 'excerpt') {
$post = '';
$post .= get_the_excerpt();
$post = apply_filters('the_excerpt',$post);
} elseif ( strtolower($thematic_content_length) == 'none') {
} else {
$post = get_the_content(more_text());
$post = apply_filters('the_content', $post);
$post = str_replace(']]>', ']]&gt;', $post);
$post .= $belowcontent;
}
echo apply_filters('thematic_post', $post);
} // end content


Jorge Ledesma comments:

trying now


enodekciw comments:

// Creates the post content
function childtheme_override_content() {
global $thematic_content_length;
$belowcontent = '';
$linked = get_post_meta(get_the_ID(), 'linked_list_url', true);
if($linked != '') {
$belowcontent = '<br/><span class="meta-utility">Jump to this <a href="' . $linked . '">linked &#x279a;</a></span>';
}


if ( strtolower($thematic_content_length) == 'full' ) {
$post = get_the_content(more_text());
$post = apply_filters('the_content', $post);
$post = str_replace(']]>', ']]&gt;', $post);
$post .= $belowcontent;
} elseif ( strtolower($thematic_content_length) == 'excerpt') {
$post = '';
$post .= get_the_excerpt();
$post = apply_filters('the_excerpt',$post);
} elseif ( strtolower($thematic_content_length) == 'none') {
} else {
$post = get_the_content(more_text());
$post = apply_filters('the_content', $post);
$post = str_replace(']]>', ']]&gt;', $post);
$post .= $belowcontent;
}
echo apply_filters('thematic_post', $post);
} // end content


added if not blank condition


Jorge Ledesma comments:

This works great but the link shows up on all post, only the linked list post should the link show up. thanks


enodekciw comments:

that correction I've added above should do the trick ;)


Jorge Ledesma comments:

That worked but its not wrap in <h6></h6> tags, is this possible. :)


Jorge Ledesma comments:

Or can this be blockquoted the whole thing wrapped in <blockquote></blockquote>


enodekciw comments:

find this line in my code snippet:


$belowcontent = '<br/><span class="meta-utility">Jump to this <a href="' . $linked . '">linked &#x279a;</a></span>';


as you should understand, $belowcontent variable holds everything that should be below the content, so just change that variables content with anything you want, for example:


$belowcontent = '<br/><h6>Jump to this <a href="' . $linked . '">linked &#x279a;</a></h6>';


I hope this helps you ;)


enodekciw comments:

$belowcontent = '<br/><blockquote>Jump to this <a href="' . $linked . '">linked &#x279a;</a></blockquote>';

this will output that line wrapped as a blockquote


enodekciw comments:

oh hell, blockquote tags was bad idea to use here ;)
anyway, from the example with h6 tags, you should now understand how to manipulate the markup of that line.

2010-10-29

idt answers:

Can I take a look at the code of your singe.php file please?

2010-10-29

Maor Barazany answers:

Add this to your <strong>functions.php </strong>file of your child theme


<?php
function tc_add_linked_feature($content) {
$my_link = get_post_meta(get_the_ID(), 'linked_list_url', true);
if ($my_link != '') { ?>
$addition = '<br /><span class="meta-utility"><a href="'.$my_link.'">Link &#x279a;</a></span>';
$content .= $addition;
<?php } ?>
return $content;
}

add_filter('the_content', 'tc_add_linked_feature');


Maor Barazany comments:

A small correction, put this:

<?php
function tc_add_linked_feature($content) {
$my_link = get_post_meta(get_the_ID(), 'linked_list_url', true);
if ($my_link != '') {
$addition = '<br /><span class="meta-utility"><a href="'.$my_link.'">Link &#x279a;</a></span>';
$content .= $addition;
}
return $content;
}

add_filter('the_content', 'tc_add_linked_feature');
?>


Jorge Ledesma comments:

where exactly on the functions.php


Maor Barazany comments:

At the end of the file, after the last line.


Jorge Ledesma comments:

For some reason its the little arrow is showing on the home page