Adding a hyperlink to every comment - php

Here is an image of my comment format: http://oi40.tinypic.com/8w07jt.jpg
The hyperlink to each individual comment is the date and time with the url in the format of, for example: /nottingham/#comment-184
After going through my comment templates I found that these two functions do the following,
get_comments_link : Retrieves the link to the current post comments
AND
comments_link: Displays the link to the current post comments
The problem is I have no idea where to include these functions so it creates a hyperlink to every comment within every comment. Once this link has been created I'd also like to assign a div to it so I can format it to be in the bottom right corner of each comment.
My final goal is to manipulate the link so rather than the comment link itself it will automatically work in the facebook.com/sharer.php which I feel I can do myself once I figure out the previous part. Essentially it will be a share on facebook button, but I have found no plugins which do this yet and thought describing it as a hyperlink would be an easier way to explain what I'm trying to do.
Elsewhere I've been told the following: but not sure how to implement this...
In functions.php I'd add a 'get_comments_link' filter to return the desired link, including the tag you need. Note that this is a filter, not a function. There is function with the same name, but it's part of WordPress itself. Use the filter to add a div to the existing link. Then style the new div to position it where you want it. I notice that the Photoria theme repositions the Reply link, which is coded at the bottom but displayed at the top. In the same way, your new will be coded at the top but displayed at the bottom. Also see add_filter in the Codex. Add the new div to $link before returning it. The new div will need a class attribute so that you can work with it in CSS to make it look the way you want.
I hope I've made the question clear, please ask if I haven't. Thanks in advance!

You need to edit your comment template in your Wordpress theme.
Default is located in /comments.php
Some more informations could be found here : http://codex.wordpress.org/Function_Reference/comments_template

Finally answered it myself, the code used to display the comment link was:
<img src=""
Which was inserted in my comments template file within my comments body div which I then put into another div so I could format it itself to where I wanted it positioned.
Currently in the process of making the link automatically share through the facebook sharer...
Hope this helps anyone with the same problem.

Related

Modify the footer of each post PHPBB?

I want to add the ShareThis buttons for every topic on my forum. I have already modified the overall header and added the code to the head tag.
How can i modify the templates so they appear for each topic? Also is there anyway to add them to the footer of or under each topics first post rather than besides the title?
I am using PHPBB 3.1.10
Many thanks
I don't know which code fragment you are trying to inject, but I assume you have already included a link to a javascript script in your header (you can also include it in your footer instead) and now you need to add the html element of the button that triggers this script.
If you want to show something only in the topics page, then you should change the styles/your_style/template/viewtopic_body.html file. You can choose where to insert it and, depending on your style and the place, you may need to do some small modifications (e.g. using the inline style="" attribute).
If you want to show it on the footer of each post, you can try putting your element just before or after the line <!-- EVENT viewtopic_body_postrow_post_after --> in your viewtopic_body.html file. The events are like "interesting points" in the styles and you can see a list of them here.
In any case, make sure that you don't make any syntax errors (and always keep a backup). You can validate your page using the W3C validator.

Display a single blog post

I am using PHP + MySql.
My goal is to be able to click on a blog post title and have the site link to a page that will display just that blog post (pretty much like any wordpress blog).
I have searched for the way to do this over and over and cannot find any information that shows me how to and I don't even know where to start. IF someone could just point me in the right direction or to an article that will show me how to do this.
I am assuming that i need to us Jquery to create a variable that takes the ID but I really have no clue where to start.
Just wrap the title in an anchor tag with the URL of the post as the value for the href attribute
<h1>Title goes here</h1>

How to add an attribute to a link created inside a Post in Wordpress?

From a Post or Page inside Wordpress, you can add a link from the WYSIWYG toolbar, you know by clicking the chain icon.
I would like to automatically add a data attribute to the link that is rendered by doing this. I can't seem to find where in WordPress this link gets created.
This would need to be a function in the theme's directory, correct?
Any ideas?
Here's how I started hunting this one: Searched wp core for "Or link to existing content", which shows up here:
/wp-includes/class-wp-editor.php - line 808: public static function wp_link_dialog()
Also found some stuff here:
/wp-admin/includes/ajax-actions.php - search for "_ajax_linking_nonce"
It seems like there's an ajax request to get the list of linkable posts/pages, and then javascript handles the rest.
Good luck ;)

Wordpress sidebar to load specific posts

I am building a website in Wordpress and I need a sidebar that when you click the name of each post on the sidebar, it loads that specific post in the middle of the page.
I am unsure of how to go about doing this.
I am new to wordpress and php and any help is appreciated :)
Well basically as far as I understood you want to replace the current middle content with post content.
To do that you will have to use AJAX connection. You will need to pass post id to function, where you will retrieve post data and return it back to the page, where you will need to just insert it in the content.
I suggest that you check these links -
http://api.jquery.com/jQuery.ajax/
http://codex.wordpress.org/AJAX
Example -
http://net.tutsplus.com/tutorials/javascript-ajax/uploading-files-with-ajax/
http://www.1stwebdesigner.com/css/implement-ajax-wordpress-themes/
A more simple solution would be just to add the_permalink(); to page link, so it directly links to the post.

Category specific calendar in wordpress (get_calendar)

I cannot find a category specific calendar, or any sample code to allow me to get slightly dirty... Anyone know of a category specific calendar so I can call it for example:
get_calendar(true, true, $cat_id);
Otherwise I will have to copy the get_calendar function and make my own get post by category loops sigh
Ended up making my own calendar.
This is a really shaky way of doing it but it works great.
Create a new page in your template directory called “the-calendar.php” place the following code in it: http://pastebin.com/sUSzJMWM
Create a new script file (that has access to jquery).
Put the following code in it
(MAKE SURE YOU HAVE SET site_url to equal “get_template(‘blog_info’) . ‘/’”): http://pastebin.com/Q16ibAZ0
Now just include this wherever you want the calendar to be (keeping in mind that the above script must be accessible):
http://pastebin.com/fyhXrCiW
Don’t forget to style your date.php page in your wordpress theme directory!!!
Here is some default styling that looks awful but should get you started:
http://pastebin.com/NMauFJWq
The Calendar works by calling (via AJAX) an external PHP file that gathers and echos the HTML code that generates the table. On the success of the AJAX, it just fills the specific div with the returning html.
Please feel free to expand on the code and also ask questions if you can’t get it to work! I hope it saves you some time!

Categories