Version Description
Download this release
Release Info
| Developer | markjaquith |
| Plugin | |
| Version | 1.0 |
| Comparing to | |
| See all releases | |
Version 1.0
- page-links-to.php +55 -0
page-links-to.php
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/*
|
| 3 |
+
Plugin Name: Page Links To
|
| 4 |
+
Plugin URI: http://txfx.net/code/wordpress/page-links-to/
|
| 5 |
+
Description: Allows you to set a "links_to" meta key with a URI value that will be be used when listing WP pages. Good for setting up navigational links to non-WP sections of your
|
| 6 |
+
Version: 1.0
|
| 7 |
+
Author URI: http://txfx.net/
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
/*
|
| 11 |
+
=== INSTRUCTIONS ===
|
| 12 |
+
1) upload this file to /wp-content/plugins/
|
| 13 |
+
2) activate this plugin in the WordPress interface
|
| 14 |
+
3) create a new page with a title of your choosing, and with the parent page of your choosing. Leave the content of the page blank.
|
| 15 |
+
4) add a meta key "links_to" with a full URI value (like "http://google.com/") (obviously without the quotes)
|
| 16 |
+
|
| 17 |
+
That's it! Now, when you use wp_list_page(), that page should link to the "links_to" value, instead of its page
|
| 18 |
+
*/
|
| 19 |
+
|
| 20 |
+
function txfx_get_page_links_to_meta () {
|
| 21 |
+
global $wpdb, $page_links_to_cache;
|
| 22 |
+
|
| 23 |
+
if (!isset($page_links_to_cache)) {
|
| 24 |
+
|
| 25 |
+
$links_to = $wpdb->get_results(
|
| 26 |
+
"SELECT post_id, meta_value " .
|
| 27 |
+
"FROM $wpdb->postmeta, $wpdb->posts " .
|
| 28 |
+
"WHERE post_id = ID AND meta_key = 'links_to' AND post_status = 'static'");
|
| 29 |
+
} else {
|
| 30 |
+
return $page_links_to_cache;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
if (!$links_to) {
|
| 34 |
+
$page_links_to_cache = false;
|
| 35 |
+
return false;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
foreach ($links_to as $link) {
|
| 39 |
+
$page_links_to_cache[$link->post_id] = $link->meta_value;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
return $page_links_to_cache;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
function txfx_filter_links_to_pages ($link, $page_id) {
|
| 46 |
+
$page_links_to_cache = txfx_get_page_links_to_meta();
|
| 47 |
+
|
| 48 |
+
if ( $page_links_to_cache[$page_id] )
|
| 49 |
+
$link = $page_links_to_cache[$page_id];
|
| 50 |
+
|
| 51 |
+
return $link;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
add_filter('page_link', 'txfx_filter_links_to_pages', 10, 2);
|
| 55 |
+
?>
|
