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

Recode previous snippet from Linked List Plugin to new theme WordPress

  • SOLVED

Go to this [[LINK href="http://www.jorgeledesma.net/diamonds-and-debt/"]]post[[/LINK]] and notice the post meta has:

Author jorge ledesma
Categories Living
Tags consumerism


So far so good right, I'm going to make this easy for you guys.
I have a linked list plugin running on the site and I'd like to add another "post-tags meta-item" called: Link and then add the text Jump to this Link ➚ with the corresponding url of the linked list post. So it will look like this now

Author jorge ledesma
Categories Living
Tags consumerism
Link Jump to this Link ➚


But I only it want to show up when the post has the actual linked list post. It gets better in a previous question Maor already gave me the code, so you would have to fix the code to match this theme single.php which is included as well.

Maor's code from my previous theme modification is the following:

<?php $my_link = get_post_meta(get_the_ID(), 'linked_list_url', true);

if ($my_link != '') { ?>

<span class="meta-utility">Jump to this <a href="<?php echo $my_link;?>">Link ➚</a></span>

<?php } ?>



But keep in mind I want it to say "Link Jump to this Link ➚"

Here is the chunk of code from my current theme's single.php
<span class="post-tags meta-item">
<?php printf(__('<span class="label">Categories</span> <span class="meta-content">%s</span>', 'basicmaths'), get_the_category_list(', ', '</span>')) ?>
<?php printf(__('%s', 'basicmaths'), get_the_tag_list('<span class="label">Tags</span> <span class="meta-content">', ', ', '</span>')) ?>
</span>

</div><!-- .entry-meta -->


Any question let me know. Cheers. So basically you have to rewrite that bit of code to match the semantic style of my current theme.

Answers (3)

2010-11-02

rilwis answers:

I think you just simply change change the code to:

<?php $my_link = get_post_meta(get_the_ID(), 'linked_list_url', true);
if ($my_link != '') { ?>
<span class="label">Link</span> <span class="meta-content"><a href="<?php echo $my_link;?>">Jump to this link</a></span>
<?php } ?>


Jorge Ledesma comments:

Ok, this worked, now the spacing is off, let me add the &nbsp; a few times to see if it moves.


Jorge Ledesma comments:

For some reason its not justifying the text like the other meta tags, hmm


rilwis comments:

I saw you paste the code into wrong position. Put it just below where Categories and Tags are show:

<span class="post-tags meta-item">
<?php printf(__('<span class="label">Categories</span> <span class="meta-content">%s</span>', 'basicmaths'), get_the_category_list(', ', '</span>')) ?>
<?php printf(__('%s', 'basicmaths'), get_the_tag_list('<span class="label">Tags</span> <span class="meta-content">', ', ', '</span>')) ?>

<?php $my_link = get_post_meta(get_the_ID(), 'linked_list_url', true);

if ($my_link != '') { ?>

<span class="label">Link</span> <span class="meta-content"><a href="<?php echo $my_link;?>">Jump to this link</a></span>

<?php } ?>

</span>


Jorge Ledesma comments:

ok, let me see


Jorge Ledesma comments:

I did but it looks very funny


rilwis comments:

No, still wrong position, can you send me your file to my email? [email protected]
I'll edit it and send back to you.


Jorge Ledesma comments:

emailing now

2010-11-02

Andrzej answers:

No offence, but let's be serious. $5 is too low even for reading it all.


Jorge Ledesma comments:

I gave you the code

2010-11-02

Denzel Chia answers:

combine the above two chunks of code


<span class="post-tags meta-item">

<?php printf(__('<span class="label">Categories</span> <span class="meta-content">%s</span>', 'basicmaths'), get_the_category_list(', ', '</span>')) ?>

<?php printf(__('%s', 'basicmaths'), get_the_tag_list('<span class="label">Tags</span> <span class="meta-content">', ', ', '</span>')) ?>

</span>

<?php $my_link2 = get_post_meta(get_the_ID(), 'linked_list_url', true);



if ($my_link2 != '') { ?>



<span class="meta-utility">Link Jump to this <a href="<?php echo $my_link2;?>">Link ➚</a></span>



<?php } ?>

</div><!-- .entry-meta -->


Jorge Ledesma comments:

They have different names for the span class and plus its not what I wrote :)


Denzel Chia comments:

Previous version has HTML error,
use this;


<span class="post-tags meta-item">
<?php printf(__('<span class="label">Categories</span> <span class="meta-content">%s</span>', 'basicmaths'), get_the_category_list(', ', '</span>')) ?>
<?php printf(__('%s', 'basicmaths'), get_the_tag_list('<span class="label">Tags</span> <span class="meta-content">', ', ', '</span>')) ?>

<?php $my_link2 = get_post_meta(get_the_ID(), 'linked_list_url', true);

if ($my_link2 != '') { ?>

<span class="meta-utility">Link Jump to this <a href="<?php echo $my_link2;?>">Link ➚</a></span>

<?php } ?>

</span>

</div><!-- .entry-meta -->


Jorge Ledesma comments:

but look at the names they don't match and the wording is off though


Denzel Chia comments:

Please read carefully, I just combined both chunks of your code.
I only changed the php variable name, did not change html span tag class.

If this is not what you want, then I cannot help.

Thanks!


Denzel Chia comments:

What I did is combine your chunk from single.php with maor's code.
Changed a variable name so that it does not crash with the bottom link.

That's all.


Denzel Chia comments:

Ok, I finally understand what your say



<span class="post-tags meta-item">

<?php printf(__('<span class="label">Categories</span> <span class="meta-content">%s</span>', 'basicmaths'), get_the_category_list(', ', '</span>')) ?>

<?php printf(__('%s', 'basicmaths'), get_the_tag_list('<span class="label">Tags</span> <span class="meta-content">', ', ', '</span>')) ?>



<?php $my_link2 = get_post_meta(get_the_ID(), 'linked_list_url', true);



if ($my_link2 != '') { ?>



<span class="label">Link Jump to this <a href="<?php echo $my_link2;?>">Link ➚</a></span>



<?php } ?>



</span>



</div><!-- .entry-meta -->


Just change the span class to label.


Jorge Ledesma comments:

trying I'm trying


Denzel Chia comments:

@rilwis - Great you just copied my answer and add a span tag with class label.

Nevermind, I will leave this thread to you.

See ya.