WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Social buttons help (15 posts)

  1. Tara
    Member
    Posted 4 years ago #

    Hi all,

    Please guide me as to where I can place (i.e., which file and location within that file) social buttons manually.

    Thank a lot.

  2. I haven't working directly with the Twenty Ten templates, but I'd imagine that you'd insert the code into the Loop and Single templates, somewhere below <?php the_content(); ?>

    Most "social button" plugin insert their "buttons" automatically. You may want to consider using one of those instead.

  3. Tara
    Member
    Posted 4 years ago #

    Thanks MacManX for taking time to help me out.

    Following your pointer, this is what I found so far:

    1. I placed in single.php and it works great. And it does not generate any W3C validation error. BOT the buttons only show up on the comments page, nothing on the Index page.

    2. When I put them in the loop.php, they show up on the index page beutifully. HOWEVER, they also generate W3C validation error as follows:

    http://www.example.com/blog/2010/04/22/testing-post/ for attribute href on element a: WHITESPACE in QUERY.
    Syntax of IRI reference:
    Any URL. For example: /hello, #canvas, or http://example.org/. Characters should be represented in NFC and spaces should be escaped as %20.

    How can I get rid of this validation error. I tried placing the buttons at different location in loop.php, no luck.

    Thanks MacManX for your time.

  4. How can I get rid of this validation error.

    It's hard to say without actually seeing your site.

  5. Tara
    Member
    Posted 4 years ago #

    Thanks MacManX for your help.

    Playing with it I found out that:

    1. If the title of the post is limited to just one word then there is no error.
    2. But if the title of the post is more than one word, there is the error (white space).

    Since I am not a dev or programmer, it does not tell me much other than that there may be a bug in 3.0. Because on my personal blog site that is still using 2.9.2 has these social buttons installed manually and there is no such error generated.

    I also tried "sexybookmark" pluging on this test site (wp3.0, twentyten), I noticed that although their social buttons do not generate this error, BUT their email does generate the same error that I am getting with manual experiment.

    This also reinforces my notion that there may be a bug in 3.0 that generates these "white space" error.

    I want to thank you again for your time and patient.

  6. That's very strange. I doubt it's a bug with 3.0. It sounds more like it's a problem with how your social buttons are generating the links.

    Just to test, try this plugin:

    http://wordpress.org/extend/plugins/add-to-any/

  7. Tara
    Member
    Posted 4 years ago #

    Thanks MacManx,

    I tried "add-to-any", and it works fine and does not generate the same error I was getting with manual placement of buttons and "sexybookmarks" plugin.

    I was really trying to avoid these plugins - they include so many buttons; probably 99% are totally irrelevant.

    Although "sexybookmarks" let me chose the buttons I want, but it generates the same error I get using my manual placement of buttons (in loop.php). That renders the "sexybookmarks" plugin undesirable.

    is there anyway I can keep the manual placement in loop.php and not generate that "white space" error?

    here one example of the button link I am manually using (all buttons generate the same error):

    &title=<?php the_title(); ?>" target="_blank"><img src="http://www.Example.Com/images/gur_facebook.png" title="Facebook!" height="16" width="16" alt="Facebook" />

    Thanks again.

  8. I'm not sure on the specifics, but I recommend cross-referencing how the Add to Any plugin generates the links vs. how you're currently generating the links with the manually placed buttons.

  9. Tara
    Member
    Posted 4 years ago #

    Hi MacManx,
    Thanks again forr the reply.

    I recommend cross-referencing how the Add to Any plugin generates the links vs. how you're currently generating the links with the manually placed buttons

    I tried that, but, since I am new to all this, I could not ascertain as to how exactly they call the URL and the Title. So i was unable to compare with my call for the URL and Title (listed in my previous post, which works fine in 2.92).

    Any suggestion would be greatly appreciated. Thanks.

  10. wordmotes
    Member
    Posted 3 years ago #

    I recognized the same problem using WordPress 3.0.1 and Twentyten 1.1

    The problem is "the_title" if you use it in links you get a invalid markup because of "WHITESPACE in QUERY".

    I'm no coder or developer as well so I have no answer how the problem can be solved.

    We need "%20" for the whitespace, but I've no idea where you can add this. Maybe anyone of you have a idea for this?

  11. Tara
    Member
    Posted 3 years ago #

    after spending lots of time, i found out the following to work, and it does not generate W3C error as well.

    replace this:
    title=<?php the_title(); ?>"

    With this:
    title=<?php echo str_replace( ' ', '', get_the_title()); ?>"

    hope this helps all others who want to set social buttons without plugins.

  12. wordmotes
    Member
    Posted 3 years ago #

    You set me a big smile on my face. This works, but you've no spaces between longer articles, with this solution. If you add the following to your code, it should also work with spaces in the article.

    <?php echo str_replace( ' ', '%20', get_the_title()); ?>

    I hope I can give you a little bit back with it.

  13. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    this might be useful as well, not just dealing with spaces in title:

    rawurlencode($string)

    http://php.net/manual/en/function.rawurlencode.php
    http://www.w3schools.com/TAGS/ref_urlencode.asp

  14. Tara
    Member
    Posted 3 years ago #

    Thanks wordmote and alchymyth.

    @wordmote,

    with both solutions:

    title=<?php echo str_replace( ' ', '', get_the_title()); ?>"

    and

    title=<?php echo str_replace( ' ', '%20', get_the_title()); ?>"

    I get the same jubled up title.

    For example, "Hello world" appears as "Helloworld".

    any suggestion? Thanks

  15. Tara
    Member
    Posted 3 years ago #

    ignore previous post.:)

Topic Closed

This topic has been closed to new replies.

About this Topic