How do i add OnClick event (html) to links?

Discussion in 'WordPress' started by Paulie, May 25, 2010.

  1. #1
    With wordpress if your making a new post you can enter in html coding, but when adding links it only seems to let you enter a URL but not HTML.

    Im assuming this is just the way the control system is though am wondering if anyone knows what file i need to look for via ftp to be able to edit the links?

    Im trying to add an onclick event to one of the links in my blog.

    Any ideas?

    Paulie
     
    Paulie, May 25, 2010 IP
  2. reelstuff

    reelstuff Active Member

    Messages:
    195
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #2
    This may not be what you want to hear, but when I read you post it says, to me at least, that you want javascript, listen closely, and you may hear it too, seriously,

    That is just one method, there are like hundreds, of way to do this, using javascript,
     
    reelstuff, May 25, 2010 IP
  3. Paulie

    Paulie Active Member

    Messages:
    749
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    81
    #3
    That doesnt answer my question and i have no clue what the code is you have just posted.

    As my OP says, im trying to add an onclick event to one of links, i can do ths with blog posts, but not with the links itself as they only have the option for the URL to be entered and NOT html.

    Anyone?
     
    Paulie, May 26, 2010 IP
  4. seogawd

    seogawd Active Member

    Messages:
    315
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    60
    #4
    what kind of event are you trying to make happen
     
    seogawd, May 26, 2010 IP
  5. adbox

    adbox Well-Known Member

    Messages:
    906
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    155
    Digital Goods:
    1
    #5
    After adding a link in the regularl way, switch over to html mode in your wysiwyg editor, and add what you need to do. This will help:

    http://www.pageresource.com/jscript/jlinktut.htm



     
    adbox, May 26, 2010 IP
  6. Paulie

    Paulie Active Member

    Messages:
    749
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    81
    #6
    an onlcick event, so it would be the url followed by onclick= etc

    You can add html coding to posts it would seem but not to sidebar links

    Cheers adbox but you cant switch to html on sidebar links, ONLY on posts itself, unless im missing something
     
    Paulie, May 26, 2010 IP
  7. dcristo

    dcristo Illustrious Member

    Messages:
    19,797
    Likes Received:
    1,201
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    5
    #7
    Yes you are missing something because you should be able to edit the html of links even if they are located in the sidebar. If it's a widget text box, edit the code manually, or you may have to edit the template code for the theme.
     
    dcristo, May 26, 2010 IP
  8. Paulie

    Paulie Active Member

    Messages:
    749
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    81
    #8
    If i could find the correct file within ftp id be able to make the changes. Its just the control panel for wordpress doesnt seem to let you make html changes to the sidebar.

    Have tried editing the theme for sidebar, but then i dont see my links, and the onclick event is only specific to one of the links, hence trying to find the file with the sidebar links.
     
    Paulie, May 26, 2010 IP
  9. dcristo

    dcristo Illustrious Member

    Messages:
    19,797
    Likes Received:
    1,201
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    5
    #9
    Paulie, you can edit the template files in the wordpress admin. Click on Apprearance and you will see that you can edit the files. If it's not a widgetized theme, it's more then likely the sidebar template file.
     
    dcristo, May 26, 2010 IP
  10. Paulie

    Paulie Active Member

    Messages:
    749
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    81
    #10
    The problem with that is that you cant see the links when editing through the wordpress admin. So if i go to apprearance, editor, sidebar.php it wont actually contain the links in the sidebar. Seems to be the same for all files that are editable through wp admin.

    If i go to links>edit i can only enter the URL as it wont allow me to enter a onclick event in the URL box and in that section there seems to be no html editor for the links.
     
    Paulie, May 26, 2010 IP
  11. dcristo

    dcristo Illustrious Member

    Messages:
    19,797
    Likes Received:
    1,201
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    5
    #11
    I understand the problem now! What I would do is add the blogroll links manually instead of adding the links in the admin panel, so you can edit the html. In other words, hard code the links into the template or using widgets.
     
    dcristo, May 26, 2010 IP
  12. Paulie

    Paulie Active Member

    Messages:
    749
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    81
    #12
    Im so glad you understand my problem now :D

    Hard-coding is EXACTLY what i want to do, but im not sure how? Im not sure where id be looking in the files to find the correct file that contains the sidebar links to harcode. As for widgets, havent used them at all yet so not sure how they work.

    But hardcoding is def what ive been trying to do with the sidebar links, and im still going through the tons of files that is contained within wordpress (ftp) just cant find the right one that contains the links
     
    Paulie, May 26, 2010 IP
  13. dcristo

    dcristo Illustrious Member

    Messages:
    19,797
    Likes Received:
    1,201
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    5
    #13
    You should see php code in the sidebar template to display the links. Replace this code with html to display the links.

    Alternatively, you could add the link html in a text box widget, but I would try the first option and see how you go.
     
    dcristo, May 26, 2010 IP
  14. Paulie

    Paulie Active Member

    Messages:
    749
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    81
    #14
    Sidebar.php shows me

    <div id="right_bar" class="sidebar">
    	<ul class="sidebar_list">
    <?php 
    		if (!function_exists('dynamic_sidebar') || !dynamic_sidebar(2)) : ?>
    		<li class="widget">
    			<h2>Search This Site</h2>
    			<?php include (TEMPLATEPATH . '/searchform.php'); ?>
    		</li>
    		<li class="widget">
    			<h2>Categories</h2>
    			<ul>
    				<?php wp_list_categories('title_li=0'); ?>
    			</ul>
    		</li>
    <?php get_links_list('id'); ?>
    <?php 
    		endif; ?>
    	</ul>
    </div>
    Code (markup):
    It doesnt have any of my links in there so i guessed it was the wrong file that actually contained the links.
     
    Paulie, May 26, 2010 IP
  15. dcristo

    dcristo Illustrious Member

    Messages:
    19,797
    Likes Received:
    1,201
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    5
    #15
    <?php get_links_list('id'); ?> is what displays the blogroll links.

    Replace this code with the link html (look at the source code and it should be easy figuring it out).
     
    dcristo, May 26, 2010 IP
  16. Paulie

    Paulie Active Member

    Messages:
    749
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    81
    #16
    Ok i see what your saying but isnt those links the "pages" links rather than "links"

    I say that as it says <?php wp_list_categories('title_li=0'); ?>

    If it helps, looking at source code shows me that the links are under id="linkcat-3

    Not sure if that helps or not
     
    Paulie, May 26, 2010 IP
  17. dcristo

    dcristo Illustrious Member

    Messages:
    19,797
    Likes Received:
    1,201
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    5
    #17
    <?php wp_list_categories('title_li=0'); ?> is what displays the categories.
     
    dcristo, May 26, 2010 IP
  18. Paulie

    Paulie Active Member

    Messages:
    749
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    81
    #18
    But is there not a difference between blogroll links and the "links section"?

    One is linking the different categories, whilst the one i am trying to edit is under Links>Edit
     
    Paulie, May 26, 2010 IP
  19. dcristo

    dcristo Illustrious Member

    Messages:
    19,797
    Likes Received:
    1,201
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    5
    #19
    which is why i suggested that you replace this code <?php get_links_list('id'); ?>

    if it doesn't work you can always revert back to the old code, but it should work.
     
    dcristo, May 26, 2010 IP
  20. Paulie

    Paulie Active Member

    Messages:
    749
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    81
    #20
    It does work but loses the category, alignment etc.

    Would be good to know where the link list actually is but at least im getting somewhere.
     
    Paulie, May 26, 2010 IP