megabrutal
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Custom Field from database tableMeanwhile, I figured it out myself.
I wrote a small plugin that does the work:
<?php /* Plugin Name: Replace Custom Field By Database Entry Version: 0.1 Author: MegaBrutal */ function rcfbde_install () { global $wpdb; $table_name = $wpdb->prefix . "cftolink"; $sql = "CREATE TABLE IF NOT EXISTS '" . $table_name . "' ( 'id' mediumint unsigned NOT NULL AUTO_INCREMENT, 'title' text NOT NULL, 'url' text DEFAULT NULL, PRIMARY KEY ('id') );"; $sql = $wpdb->prepare($sql); $wpdb->query($sql); } function filter_rcfbde ($line, $key, $value) { global $wpdb; $table_name = $wpdb->prefix . "cftolink"; $valuet = trim($value); if ('_' == $valuet[0]) { $valuen = substr($valuet, 1); $row = wp_cache_get($valuen, "cftolink"); if (false == $row) { $sql = $wpdb->prepare("SELECT * FROM '" . $table_name . "' WHERE 'id'=" . $valuen . ";"); $row = $wpdb->get_row($sql); wp_cache_set($valuen, $row, "cftolink"); } if (is_null($row->url)) { $line = str_replace($value, $row->title, $line); } else { $ahref = "<a href=\"" . $row->url . "\">" . $row->title . "</a>"; $line = str_replace($value, $ahref, $line); } } return $line; } register_activation_hook(__FILE__, 'rcfbde_install'); add_filter('the_meta_key', 'filter_rcfbde', 1, 3); ?>
I hope I chose the most efficient solution.
Forum: Fixing WordPress
In reply to: Custom Field from database tableI don’t really get it… I’ve added a the_meta() call in my templates so my metadatas are shown well. My problem is that I wouldn’t like to add the exact same and long metadata values to a bunch of posts. It’s inconvenient, redundant, and it would be a problem if I’d need to change these metas for all posts for some reason.
Forum: Fixing WordPress
In reply to: Accidentally changed URL under "Settings" – Can't loginYou have several options:
1. Login to phpMyAdmin, and manually change the “siteurl” and “home” records in the wp_options table.
2. Open up wp-config.php, and add these lines:define('WP_HOME','https://your.correct.url.com/path/to/wordpress'); define('WP_SITEURL','https://your.correct.url.com/path/to/wordpress');
Then you may access your site. Go to admin, change back the site url on the admin page as well, then remove the above lines from your wp-config.php.
For more options, see: https://codex.www.ads-software.com/Changing_The_Site_URL
Forum: Fixing WordPress
In reply to: Separating posts by categoriesThanks, it helped! ??