scriptygoddess

07 Oct, 2009

Delink Pages Plugin

Posted by: Jennifer In: WordPress|WordPress Plugins

(Plugin and this post last updated: 10/20/2009 – Latest Plugin Version: 1.1.1 – see changelog at bottom of post)

I have been wanting to do more wordpress plugin development, but it has a somewhat steep learning curve. So I'm testing the waters a bit here. I've done some testing with the plugin, but feedback is appreciated. For now, if you have problems with the plugin, leave a comment here. PLEASE include contact information (fill out the email field with a valid email address!!), a URL where you have the plugin installed, any errors you're getting, etc. The more information you give me, the more likely I will able to fix the problem.

Plugin Description

This plugin will allow you to specify certain pages to not be linked when wp_list_pages() is used in your theme. You might want to do this if you want a header for a series of subpages, but don't specifically want that header to be a real "page" or link.

For example – you have a series of pages like this:

As of version 1.1 of this plugin there are two ways you can go about doing this. You can either remove the link entirely. As in no <a> tag at all like this:

OR you can remove the link to the actual page and sawp it out for a blank link to "#".

Usage

To use the plugin, download the zip, and unzip the file. Install it by putting the scripty-delinkpage.php in your wp-content/plugins/ directory. Activate it through the WordPress admin. Then, on pages you do not want to have a link, add a custom field with a key of "delink" and a value of "true" when you want to remove the link completely, or a value of "href" when you want the href value to be "#".

Download

You can download this plugin from wordpress.org plugin directory here: Delink Pages

Changelog

Version 1.1.1
Minor bug fix to preg_replace

Version 1.1
Added option for delink to have a value of "href" when you want don't want the link to be removed entirely but be linked to "#"

Version 1.0
Initial release

21 Responses to "Delink Pages Plugin"

1 | Mark

October 8th, 2009 at 12:09 pm

Avatar

Hey Jennifer! Awesome blog. Definitely update the post when you get listed! I'm currently working on a site which needs something just like this.

Also, what happened to Above the Fold?? I was browsing through your archives and the post about how you just started your own store out of nowhere was awesome!

2 | Jennifer

October 8th, 2009 at 12:14 pm

Avatar

I got the approval to post the plugin on wordpress.org just today, but since this is my first time trying to do so, I need to read through specifically what I need to do to get it up there :)

Above The Fold was a store I had created using WordPress to sell some origami pieces I made. Unfortunately, I haven't had much time for my origami hobby so I took the site down.

3 | Mark

October 8th, 2009 at 12:31 pm

Avatar

Aaah, that's cool.

By the way, in my research for the site I'm working on, I found a plug-in called "List Pages Plus" which attempts to de-link entire tiers of pages, instead of just specific pages.

It's here:
http://wordpress.org/extend/plugins/list-pages-plus/

The plugin's code is simple (or at least pretty short), so if you didn't come across it in your own research, it might be worth looking at just for the heck of it. What I didn't like about it was the WAY that it de-links stuff… by adding

onclick="return false;"

to the anchor tag. For my site I was trying to find something that either removed the anchor entirely or just appended "#" to the end of the site's base URL. Maybe I should write a plugin some time to try to do that, but I've never written one before myself =)

4 | Jennifer

October 8th, 2009 at 12:33 pm

Avatar

I had the local download for the plugin in the post… did you try using it? My version removes the anchor tag entirely…

5 | Mark

October 8th, 2009 at 12:46 pm

Avatar

I like your solution a lot, but it's not as automatic as I'm looking for on my website… that is, one can't just create another page, set its parent, and have it "just work" as a menu item. The goal is basically to have the client not have to worry about setting any meta-data besides categorization for any new pages they'd want (http://www.scriptygoddess.com/archives/2009/08/28/playing-with-post-attachments/ has already really helped me!!! ^^)

I linked the other addon because I didn't know whether or not you'd seen it when deciding what to do about the de-linking problem, and I thought it was pretty cool.

And I kind of mis-spoke in my comment… I'm trying to keep my CSS completely unaltered (to help make this process easily extendable to other clients), so I'm working on a solution which keeps the anchor tag but uses a "#" instead of the attribute to achieve un-click-ability =)

But I'd probably use your code if it was for a personal website, or if I wasn't trying to let the client add menu items should they feel like it (which is daaaangerous but I doubt the client will ever do so… it's more about letting them feel like they have/giving them that option, I guess)

But yeah, check out List Pages Plus if you haven't already.. it's pretty cool, and the code's short enough that it might even help you dive deeper into the world of custom WordPress plugin creation! (nooot something I've done myself, though)

6 | Guillermo

October 9th, 2009 at 12:46 am

Avatar

Awesome! This is a feature that I have been implemented in a more manual way in some sites and this is a great solution.
Thanks for your job!

8 | - leg med nye medier. Eller noget.

October 10th, 2009 at 1:30 am

Avatar

[…] scriptygoddess » Blog Archive » Delink Pages Plugin (tags: wordpress plugin) […]

10 | Frank P. Walentynowicz

October 19th, 2009 at 7:58 pm

Avatar

Hi Jennifer, I've downloaded your plugin from WordPress repository but it didn't work. I've made some modifications to your code and made it work. If you would like to see my solution read this article on my website.

11 | Jennifer

October 19th, 2009 at 9:33 pm

Avatar

Hi Frank, your modification does something I didn't want the plugin to do (at least for the purposes when I wrote it). For my purposes, I wanted the link to be removed *completely* – as in NO a href="#" nothing … just a plain text header. However, your change is useful in some circumstances… what would probably be best is to combine the two and make it an option – to either remove the link entirely – or just to remove the value in the href and replace it with "#"…

12 | Jennifer

October 20th, 2009 at 9:27 am

Avatar

FYI – for anyone following along via comments. I've updated the plugin to allow for the link to also be pointed just to "#". All you need to do is instead of setting "delink" to "true" – just set it to "href". Updated plugin should be up on wordpress.org now too…

13 | Frank P. Walentynowicz

October 20th, 2009 at 1:49 pm

Avatar

Hi Jennifer. What I meant saying that plugin didn't work is that it leaves output from wp_list_pages unchanged in any way. It applies to both versions 1.0 and 1.1. When I used standard string functions instead of preg_quote and preg_replace the plugin made intended changes ( delink,true – stripped link entirely, delink,href – made 'href="#"' change with no problem).

14 | Jennifer

October 20th, 2009 at 2:40 pm

Avatar

Well, on the sites I have this running, obviously it works for me so there is something unique in your setup that is preventing it from working. I think preg_replace might be more efficient so long term I'd prefer to stick with that rather than give up and do a string loop. So I'd like to understand *why* it's not working for you.

What other plugins are you using? What version of php is on your server?

15 | Frank P. Walentynowicz

October 20th, 2009 at 4:54 pm

Avatar

WP 2.8.4, PHP 5.2.5, it works on clean installation with no plugins. Does not work with All in One SEO Pack 1.6.7. This plugin is too important to be disabled. Still, my solution works with tons of other plugins. One warning about delink,true. It messes up navigation (horizontal top, vertical submenus). However, delink,href works for all themes.

16 | Jennifer

October 21st, 2009 at 3:53 pm

Avatar

I confirmed with Frank – 1.1.1 works for him now. :)

17 | zoe

May 12th, 2010 at 12:22 am

Avatar

i cannot work for the link pages plug on my website..i dont know what is the problem..who can helping me?

18 | Jennifer

May 12th, 2010 at 7:40 am

Avatar

Zoe – can you post more details: Link to where you have this installed. If you're getting errors, what errors are you getting. What have you put in for custom fields… That way I can try to understand the problem and help…

19 | Michael

May 12th, 2010 at 3:42 pm

Avatar

Hi Scripty,

I was searching around for a solution to this problem for quite a while, so I was interested to see your code. I always figured it could be done with regular expressions, but I never understood them well enough to do it myself.

I ended up taking a different approach. My plugin solves the problem Mark was describing before, about having the parent pages unlinked automatically as the client builds the page hierarchy. I also provided support for dummy ('#') links, building on your example. Here it is; I'm curious to know what you think of it.

http://www.ambrosite.com/plugins/unlink-parent-pages-for-wordpress

20 | Neal

September 20th, 2010 at 2:07 am

Avatar

Hi Jennifer,

Trying out your DeLink Plugin. Thank you. It works as you say but… if I use "true", it changes how my link looks, if I use href, it's how I like it but the cursor still changes to a hand so that it looks like a link when I don't want it to be. See the last two links in my site. There is Test, which is set to href, and tt which is true.

The theme is an Artisteer generated theme if that makes any difference.

thank you for any help. Neal

21 | Frances

February 10th, 2011 at 10:46 am

Avatar

Hi Jennifer!

Your Delink Pages plugin worked like a charm. I did have the same problem as Neal 9/20/10 (link font changed to a smaller font), but the problem was solved when I changed the value from # to href it was fine.

I tried another delink plugin, but couldn't get it to work, and there were no directions. After a little bit of searching, I found yours — and your instructions were easy to understand (I am new to WordPress).

Thank you so much for developing this fabulous and easy to understand plugin! Frances

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements