WordPress Get next and previous post URL permalink

Hello, This post as the title says talks about getting URL for next and previous post. Please note that post is not same as page. All the required functions and hints can be found in link-template.php file under wp-includes Let me show you how you can get permalinks for next and previous post without doing anything fancy. Get Previous post URL First of all we will get hold of post object for the previous post as shown below We will use adjacent_post_link() function. Definition of this function is given below [crayon-59050305e3d93427258195/] So to get the previous post link do this [crayon-59050305e3da9838132101/] Above usage of function get_adjacent_post pass on default values for all the params function accepts. You can pass on custom values for it to behave differently. Now lets check how we can get next post permalink Get Next post URL Pretty much the same functionality but with one core difference. $previous should be set to false as shown below [crayon-59050305e3db0569371584/]     As you can see that its pretty straight forward. I hope this helps. Please let me know if you have something to add of the above code can be improved. Don't forget to leave you comments. Once again I would like to add that getting post link is not same as getting page link. Here is a useful read from wordpress codex http://codex.wordpress.org/Next_and_Previous_Links The above post explains how to get page URLs. If you have any questions please let me know so that either myself or any other reader reading this post can answer your question.s Cheers         … [Read more...]

wordpress youtube channel embed plugin

Hello, A couple of week back I wrote a jQuery plugin to embed custom youtube channel on your webpage. I thought it would be good to do a wordpress plugin too to the same. Thus I began this plugin. Now because I've already done few wordpress plugins thus development of this one was a breeze because I already have the jQuery plugin code that I developed and I already have the functions that I wish to use. Purchase Pro version of this plugin today at a very special price! just $14.99  Version 3.0 is out now. ChangeLog: Seamless channel or playlist embed to any Wordpress post with Youtube API v3 6 Months Free email support with Single Site License 1 Year Free email support with Unlimited Site License And much more View PRO Details and Purchase   Plugin name I named this plugin as jcwp youtube channel embed , I thought its a good name :) I am still obsessed putting jc somehow in the plugin name Lets check what the options screen looks like Screenshots A screen shot of the Options page thumbnails mode   Lightboxed video when  thumbnail is clicked   List mode     There are many other options you can control how your videos are displayed. I've intentionally taken out autoplay settings because I think that do not add anything to the usability of the plugin. Options Channel mode This tells the plugin how to render the videos. Thumbnail mode will display static images for your videos and when user clicks on it video lightbox will be shown List|Thumbnails Channel name : This will be the channel name which you wish to include Maximum results Number of videos to display Start Index  Pointer from where the videos should be shown. Handy, if you want to show videos from a given position Filter by keyword Look for keyword in the video title and filter the results Thumbnail width For thumbnail mode Video width Target width of the video Show video title Would you like to … [Read more...]

wordpress simple table of contents plugin

Hi Guys, Well I thought this could be a good addition to my Blog if I end up offering Table Of Contents for visitors to browse an article more efficiently. That's when I decided to go ahead with this plugin. This  plugin is called "JCWP Simple table of contents" What does this plugin do? Well it created a table on contents for your post completely on client side without putting any extra pressure on load times of your article. Here are some screens that will tell you what this plugin does Let me explain a bit what above settings means Enabled:  You can enable or disable this plugin without actually deactivating the plugin. When you disable this plugin that means Table of contents will not appear at all. Article parent Tag: You will seldom need to change this because its standard all across the WordPress Blog. However if your article is wrapped in some other class other than .entry-content then you will need to mention it here. Scroll speed: You can control scroll speed when user is browsing from header A to header B Text length per Item: Sometimes out header text is way to long. You can limit the number of characters displayed in the Table of contents by setting this value Fancy Scroll: This plugin can make use of jScrollPane, you can beautify your TOC scroll by setting this value. A scroll will appear when height of your TOC exceeds the Table default height that you set. Auto minimize: Yes if you don't want TOC always visible to the user. User hovers on TOC triggers show/hide of TOC Default height: I would recommend that it should be atleast 300px but you can set it to whatever you like. Table title: Default is "Table of contents" I recommend that you shouldn't set it more than 30 character in length. Easing animation: Just in case you want something other than linear animation when scroll happens. Position: Position your TOC to wherever you like it. Powered by: Well this is my 5th WP plugin and your support matters to … [Read more...]

WordPress check if post or page or home page

Hi Guys, Some times while developing a plugin we need to check whether a feature can be enabled or disabled based on if a webpage is a Wordpress type: POST Wordpress type: PAGE Wordpress type: HOMEPAGE There are few ways you can check that but here are some core wordpress function that I use to find our the page type. Lets go through these one by one to see how we can utilize these functions Check if type is PAGE Wordpress codex supply a function called is_page() you can use this function to identify if a post is a page. So confusing right! but you get the idea Here is a quick usage of this function [crayon-59050305e4f6c452396034/] above code will print 'page' on the screen if its a page For more information please check this link out http://codex.wordpress.org/Function_Reference/is_page   Check if type is POST Alright then we need to check this too many a times. Wordpress codex supply a function called is_single() to identify if post type is POST here is a quick usage to test it out [crayon-59050305e4f7c485033585/] Above will print post if you are browsing a post. More information can be found here http://codex.wordpress.org/Function_Reference/is_single by the way is_post() has been deprecated and should not be used. Check if type is HOME PAGE/Front page This is a common occurrence with many plugins trying to do some really specific things on home page. Such as displaying ads etc. Wordpress supply two functions called is_front_page() and is_home() Here is a quick usage on that.   [crayon-59050305e4f83996251935/] Both of the above function will print home page when tested is_front_page is based on Settings->Reading->Front page displays setting, if it is is set to "Your latest posts", or when its set to "A static page" or "Front Page" value and the current Page being displayed is same as selected page this function returns true. is_home on the other hand is … [Read more...]

WordPress copy paste protection blocker plugin

Hi Guys, When I wrote my previous post about disabling the copy paste with jQuery, I thought may be its going to be a good idea to just build a plugin for Wordpress too. So I just did that and its available from wordpress Its called jcwp copy paste blocker http://wordpress.org/extend/plugins/jcwp-copy-paste-blocker/ Screenshots Above screenshot shows the options that can be configured Below is a screenshot that shows it in use. Most of the stuff is silently done, it just when you enable Alert this happens   Options Disable content selection: When this is enabled then visitors on your website will no longer able to select any text as long as javascript is enabled and they don't use other means to copy content CSS disable text selection Styles below are added to the document to disable text selection. [geshi lang="css" nums="1" target="_self" ] [crayon-59050305e5cdd787742734/] [crayon-59050305e5cec167037268/] Keyboard events You can  disable keyboard events such as ctrl+save and ctrl+select all Disable right mouse click You can disable context menu as well Protection level You can choose if you would like to protect the pages, posts, homepage or everything Alert  Just as you  see in the screenshot above Alert message Custom alert message Powered by link Enable it to show your support Installation Upload unzipped plugin directory to the /wp-content/plugins/ directory Activate the plugin through the 'Plugins' menu in WordPress Use the Plugin Options on left menu under Settings > JCWP copy paste blocker. Works on Plugin has been tested on wordpress version 3.4.1 but it should work on wordpress version 2.8 onwards without any problems Browser support Plugin has been tested on IE8+ Firefox Chrome Safari Opera has not been tested on so I am not sure if that matters given the market share. Wanna support me? No one cares, but its worth asking. Bug Report Use comments to … [Read more...]

wordpress CAPS lock detection plugin for login password fields

Hi Guys, So a few  days back I wrote a jQuery plugin to detect CAPS lock. I thought may be it won't be used as much as I first thought. Everyone have their own set of requirements. I then wrote this Wordpress plugin to justify jQuery plugin :) I thought may be this could be helpful. Lets start with couple of screenshots Settings Lets take a look on what results it will produce   This plugin gives you an options to make all password fields on your blog to show a tooltip message if user keyboard's CAPS lock is on. You can enable or disable this plugin just by setting 'Enabled' under Settings > JCWP Capslock detection > Enabled to "No" Options Enabled  Value: yes or no, defines if you want plugin to be in action or not without actually deactivating from the Wordpress Plugins screen Tooltip message This message will appear when user is trying to enter their password while they have their  CAPS on Tooltip is HTML Thanks to tipsy that we can have this. So a tooltip message can be wrtten as 'Warning: CAPS on' with the single quotes Tooltip position You can display tooltip in either top|left|right|bottom positions Use fade effect: Put it as yes if you want to use fade animation Offset: is the distance value from the password field. I'll put maximum distance to 10px. Opacity: is tooltip opacity Link to author website: Just if you would like to support me and my work. Check that checkbox. I'll appreciated that. jQuery plugin Demo that is being used in this plugin . Demo is available from my site demo pill. http://jaspreetchahal.org/examples/jccapsalert/ Download Changelog v1.0 Internally used v1.09 Submitted to wordpress Settings page added Advertisement   Donations   Installation Go to Plugins > Add New. Under Search, type in "jcwp caps lock detection". Wordpress will show a popup window will ask you to confirm your wish to install my Plugin. If this is the … [Read more...]

wordpress scroll to top plugin

Hi guys, As you may be aware that I released Scroll to top plugin for jQuery in the past. Now it was time to take that to another level. I found well may be second level of that would be wordpress. So I came up with one. The plugin is free and just in case you found yourself to be generous enough you should be able to think a little bit and consider donations. Why? because it take real money to host files and make them available for download. But that not the reason. Then reason it that I put lot of effort to come up with solutions that could help someone and most of them free of cost. hmm... hopefully I am making some sense :) Ok lets start with couple of screenshots that will tell the story about what this plugin does. Demo Scroll a bit and you will see the STT layer pop up in the centre of browser window with red background. Try to click on that and see if it takes you to the top of the page or not. Screenshots Settings     View on Page   Alright now you know exactly what this does right. So consider donations before you download :) :) kidding.. Donations Alright now that we are over the donation part let me explain what each of the settings means. Settings Active you can choose value of this settings as yes or no when you choose no then "Scroll to top" layer will not appear at all when user scrolls down. Duration The time it will take to scroll up. I recomment 1000 milli seconds. The longer this value is more frustrating it becomes. Scroll Activate At This setting tells the plugin at what depth you would like to show "Scroll to top" layer Scroll Container ID Just give a unique ID to STT text container Easing Type Select what easing animation type you would like to run Position The layer is fixed at bottom but you have flexibility to show it either at bottom-left or bottom-center or bottom-right Scroll Text If you don't like "Scroll to top" then choose whatever … [Read more...]

How to deactivate jetpack comments system

Hi Guys, With new Jetpack release after Wordpress 3.4 was released, Jetpack comes with some really good updates. One of them is their comments handling. If you have enabled their new comment system and didn't like what you saw you can choose to Deactivate the new comment system all together Lets deactivate Jetpack comments step by step First Goto Jetpack modules as shown below Now once you are in then click on Learn more button on comments module as shown below     When you click on that button Configure button will change to Deactivate as shown below   Once you deactivate your Jetpack comment system you will receive the following message and the learn more button will become activate   That's pretty much it. Your Jetpack comments systems now is gone, but you can always Activate it in case you want it back. I hope this helps Cheers   Advertisement … [Read more...]

Using open flash charts in wordpress plugins

Hi Guys, Open flash charts by John Glazebrook. His charts tool is highly customizable solution and is very potent in what you can achieve. Today I am gonna show you how you can use OFC2 within a Wordpress Plugin. There are two ways I am going to show you of using OFC2. First feeding the JSON string directly to the Chart Processor SWF and second feeding JSON through URL to the Chart processor SWF. Ok so lets write a "Hello Charts" Plugin But first I assume that you have downloaded Open flash charts from the above link and have extracted it somewhere Create a directory called hello-chart under your /wp-content/plugins folder and create a file called hello-chart.php So the final path will look like this /wp-content/plugins/hello-chart/hello-chart.php From the extracted OFC archive copy folder php-ofc-library to hello-chart folder to the path for OFC looks like this /wp-content/plugins/hello-chart/php-ofc-library Make sure that from the OFC archive you've copied open-flash-chart.swf, json2.js and swfobject.js to your hello-chart folder. I am not creating subfolders to keep things simple. So the final file system will look like this   Add admin_init action as shown below to enqueue  the js files [crayon-59050305e85d8380173859/] Now lets include the open-flash-chart.php file in our plugin. [crayon-59050305e85ee207770274/] Lets add a Navigation Menu page for an admin to view our chart. My only intention is to show you how OFC is done, there are many ways you may want to use OFC. [crayon-59050305e85f8575056964/] Now add a function disply_hello_chart as shown below Method 1 for chart implementation [crayon-59050305e8602452548987/] [crayon-59050305e860b956824403/] [crayon-59050305e8615169591493/] Advertisement   The above code has been taken from OFC's website. But you get the idea. Now when an administrator click on  "Hello Chart" navigation then a bar chart with … [Read more...]

WordPress Change title from plugin based on post or page ID

Hi Guys, There are times when you write a plugin that has to create a page and the page contents would be a shortcode handled by your plugin. Now when thats the case your landing page title will always be the same. Question is how we can change it depending on your post or page ID. This post will just give you an Idea but the final pen up has to be done by you. Look at the function below that defines a filter function that you will modify and add it to your plugin file [crayon-59050305e975e741473642/] Few assumptions in the above code but as a plugin dev you will understand what those are Now In you main plugin file just add filter to handle filter hook called wp_title as shown below [crayon-59050305e9775083226316/]   That pretty must it. Now if you are in doubt please use comments to ask questions so that others including myself can reply. I hope this helps Cheers, Advertisement … [Read more...]