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

Setting up Linked List Plugin template files for Thesis Skin WordPress

  • SOLVED

I need to have this plugin work with Thesis and the Pearsonified skin. Basically I input a custom field called linked_list_url and then it echoes as a Linked Post. From my previous questions the code is something similar to the one below but this time for Thesis 2.X and the Pearsonified Skin


<?php if (is_linked_list()): ?>

<h1><a href="<?php the_linked_list_link() ?>"> <?php the_title(); ?> &nbsp;→</a></h1>

<?php else: ?> <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>

<?php endif; ?>



Theme, Skin, and Plugin files can be downloaded here: [[LINK href="https://www.dropbox.com/sh/5xq99yrbq97atut/AAC54_e3oDzpmi4PCNEAPoa"]]link[[/LINK]]


Let me know, thanks.

Answers (1)

2014-08-02

Bob answers:

all you need to do is add this code in your thesis theme's functions.php file.

function bhavesh_linked_list_filter( $url, $post, $leavename ) {
if(is_linked_list()){
return get_the_linked_list_link();
}
return $url;
}
add_filter( 'post_link', 'bhavesh_linked_list_filter', 10, 3 );


Jorge Ledesma comments:

Great thanks let me try it.


Bob comments:

You can remove that plugin and use this code also.

Means you do not require a plugin at all!

However you have to add custom field the same way you add before.


function bhavesh_linked_list_filter( $url, $post, $leavename ) {
$linked_url = get_post_custom_values('linked_list_url');
if(!empty($linked_url[0])){
return $linked_url[0];
}
return $url;
}
add_filter( 'post_link', 'bhavesh_linked_list_filter', 10, 3 );


Jorge Ledesma comments:

B

The code is missing the "→"


I put your code on the 1st post on the test site: Linking to Google Post and I'd like it to be like this: Linking to Google Post →


Jorge Ledesma comments:

Ok that works well, one less plugin.


Jorge Ledesma comments:

deactivating the plugin causes a bug that the domain resolves but nothing below, I turned it back on.


Bob comments:

the plugin is about a link to change the title of link you need to add another filter


Jorge Ledesma comments:

If you see the code below I had added the &nbsp;→ which is what I would need as well to match.

<h1><a href="<?php the_linked_list_link() ?>"> <?php the_title(); ?> &nbsp;→</a></h1>


thanks


Bob comments:

That is direct editing in code. while this one is filter.

I am finding code please wait.


Bob comments:

here is full code with Plugin Activated.


function bhavesh_linked_list_filter( $url, $post, $leavename ) {
if(is_linked_list()){
return get_the_linked_list_link();
}
return $url;
}

add_filter( 'post_link', 'bhavesh_linked_list_filter', 10, 3 );

add_filter('the_title',"bhavesh_title");
function bhavesh_title($title){
if(is_linked_list()){
return $title."&nbsp;&rarr;";
}
return $title;
}


Jorge Ledesma comments:

Ok, that works great but I now don't have a post permalink, it automatically goes out to the link even from within the post edit screen in WP when I hit preview or view post


Bob comments:

It should only go out if you have added linked_list_url custom field in post.
can you post your website url here?


Jorge Ledesma comments:

http://www.ledesma.co


Jorge Ledesma comments:

I know what you're saying but the post should have a post permalink anyway, where within that post when someone clicks the title then the url gets echoed out that url in the custom field.


Bob comments:

I have installed everything in my localhost and everything works fine.
is there any other plugins added in website?
if the skin files are modified? or any other theme core files are modified?


Jorge Ledesma comments:

look at this image from a screen grab [[LINK href="https://www.dropbox.com/s/rm0r9l8guh7i7ti/Screenshot%202014-08-02%2015.02.24.png"]][[/LINK]]


Jorge Ledesma comments:

https://www.dropbox.com/s/rm0r9l8guh7i7ti/Screenshot%202014-08-02%2015.02.24.png


Jorge Ledesma comments:

notice that when I hover over view it shows the url in the custom field and when clicked it will go there. If I click view it should take me to the post permalink where within that post when someone clicks the title then the url gets echoed out that url in the custom field.


Bob comments:

you mean when I view post from home page it should link to that post.

but once I click on that link and go to single post page, here title should link to outer url.

am i right?




Jorge Ledesma comments:

We're getting there:

What I mean is this:

From the Home Page if you click the post title -------- it should go to the link specified by the custom field.


From Single Post Page if you click the post title -------- it should go to the link specified by the custom field. And here's the problem, I don't have a Single Post Page anymore, its gone, even from within the post dashboard, once I hit view or preview post it goes to the link specified by the custom field and not to the Single Post Page


Bob comments:

You mean

1. When user click from homepage it should go to custom field link
2. when user click from single post title it should go to custom field link
3. admin should be able to view the post and it's url from dashboard. admin should be able to view single post by clicking view link

let me know if I am wrong.


Jorge Ledesma comments:

Yes, correct !! :)


Bob comments:

Here is new full code.

function bhavesh_linked_list_filter( $url, $post, $leavename ) {
if(is_linked_list()){
return get_the_linked_list_link();
}
return $url;
}
if(!is_admin()){
add_filter( 'post_link', 'bhavesh_linked_list_filter', 10, 3 );
}

function bhavesh_title($title){
if(is_linked_list()){
if(is_single())
return '<a href="'.get_the_linked_list_link().'">'.$title."&nbsp;&rarr;</a>";
else
return $title."&nbsp;&rarr;";
}
return $title;
}
add_filter('the_title',"bhavesh_title");


Jorge Ledesma comments:

You got it !!


Jorge Ledesma comments:

Thanks just voted for you, cheers.