jgtjones
Forum Replies Created
-
Forum: Localhost Installs
In reply to: Installing a WP site to a local host from a downloaded backupI am no expert, but I move databases between desktop, laptop and remote server frequently. The way I do it is:
- Create a backup using mysqldump on a Windows PC or the standard Debian backup on the server.
- Edit the backup file to change the domain name and folder names etc., using Notepad++ on a Windows PC. Depending on which way the database is moving, the DB is uploaded/downloaded before/after editing.
- Using a MySQL Command Line Interpreter “use dbname;” followed by “source editedbackup;”. Insert your file database names. I use Putty for the server.
Very basic approach and you have to know what you are doing, but works for me.
Forum: Fixing WordPress
In reply to: Custom field "Friend" displays as a:1:{i:0;s:6:"Friend";}Thanks for the revision.
The problem goes away by simply opening the post to edit it and then saving. Don’t know why the earlier save was serialized and the later one not.
Decided to correct the data rather than test for serialized when displaying this field.
Removed much of the tedium by writing a script to identify all posts with field $relationship[0] == “a:1:…” and including an edit post link. For posterity and anyone else finding a similar problem here is my code to be read in conjunction with above.
`<?php
if (!empty($relationship)) {
if ($relationship[0] != ‘None’) {
?><span class=”ewo-text”> and <?php echo $relationship[0]; ?></span><?php
if ($current_user->display_name == ‘Administrator’) {
if (substr($relationship[0], 0, 4) == ‘a:1:’) {
?><span class = “ewo-error”>(Will Id = <?php echo $will_id[0]; edit_post_link(‘edit’, ‘ ‘, ‘.’, $id); ?>)</span><?php
}
}
}
}`
By way of explanation, the edit link appears only to the ‘Administrator’ user, the will_id is displayed for confirmation and the ‘None’ role is not displayed, useful for me but irrelevant in general. the a:1: is appropriate only for a single term.Forum: Fixing WordPress
In reply to: ajax-actions.php parse errorAll sorted.
File ajax-actions.php was corrupt. Probably due to an unreported or not noticed communications error using ftp to upload WordPress files.
This is necessary because automatic update does not work on my server.Forum: Fixing WordPress
In reply to: Custom field "Friend" displays as a:1:{i:0;s:6:"Friend";}Thanks for the suggestion, but inserting that code made no difference. Using:
if ( is_serialized($relationship) ) { ?><p>serialized</p><?php $relationship = unserialize($relationship); } else { ?><p>Not serialized</p><?php }indicated that the data was not serialized.
Any further thoughts?Forum: Fixing WordPress
In reply to: ajax-actions.php parse errorI have not upgraded because I am using Advanced Custom Fields plugin which is not guaranteed to work with 3.9
So, should I debug ajax-actions.php or ftp another cpy of the module?Forum: Fixing WordPress
In reply to: List terms and descriptions of a custom taxonomyApologies for not being consistent and including code from elsewhere. The following php code will list all terms and descriptions from all public and custom (not built in, i.e. excluding categories and tags) taxonomies:
$args=array( 'public' => true, '_builtin' => false ); $output = 'names'; // or objects $operator = 'and'; // 'and' or 'or' $taxonomies=get_taxonomies($args,$output,$operator); if ($taxonomies) { foreach ($taxonomies as $taxonomy ) { echo '<p>'. $taxonomy. '</p>'; $terms =get_terms($taxonomy, array('hide_empty' => 0)); $count=count($terms); if ( $count > 0 ) { echo "<ul>"; foreach ($terms as $term) { echo "<li>" . $term->name . ": " . $term->description . "</li>"; } echo "</ul>"; } } }Forum: Fixing WordPress
In reply to: List terms and descriptions of a custom taxonomyOk. Solved by adding an obscure argument.
Required code is:[ Moderator Note: Please post code or markup snippets between backticks or use the code button before and after your code on a new line. ]
$categories = get_terms( 'category', array( 'orderby' => 'count', 'hide_empty' => 0 ) );Forum: Fixing WordPress
In reply to: Saving custom post title built from custom fieldsI am new to WordPress and have a similar need. I have found various posts, including one described as “resolved” one year ago. Essentially your approach was correct, but ‘title_save_pre’ has been replaced by {$field_no_prefix}_save_pre which simply obscures what is going on. These guys writing WordPress modules should use plain English to help us mortals.
Presumably the code goes into functions.php. Including:`
add_filter('{$field_no_reply}_save_pre','set_custom_title');
is not going to set any post title. In my case I want to set the post title to names entered in custom post fields. These can presumably be referred to in the following way:function set_custom_title(){ if ($post->post_type == "my_custom_post_type"){ $post->post_title = $_POST['first_name'] . " " . $_POST['last_name']; } }I say presumably. I shall check it out, but if anyone knows, please say.