Hello DP, i need to add few lines of php to single.php file present in the wordpress script via plugin.. A wp plugin which will add few php codes to single.php file when activated ... can anyone help me ?
you shouldn't add lines of code to the file but rather use filters and hooks to add whatever you want. Can you give use more details about your plugin and what you are trying to achieve then we might be able to help further.
i have a website of url shorter, so i want to make a wp plugin, like when user activate it , then they will get a short url of each post via my api ..
The best way should be wrap the code into shortcode as you're using WordPress. Plugin user can use the shortcode anyway in post content to display the short url. If you anything automatic, use filter. Normally plugin cannot modify theme's file by itself (though it's not impossible).
Depending on what you want - the user getting a code when making a post, or the code / shorturl being present on the page when it's posted. The first is just making a short url and presenting it in the admin-panel where you write a post. The second involves adding the short url to the post, which can either be done by a shortcode, as suggested above, or a checkbox-setting in the admin-panel, which when checked adds a shorturl to the end of the post (for instance). This isn't very hard to do, just look up some "wordpress adding code automatically through selectors" or something similar.