Tag Info

New answers tagged

0

Early optimization is the source of 99% of the unreadable and unmaintainable code. (statistics I made up just now) There are two kinds of optimizations to make things faster to make things reasonable fast You know what is the type 1 optimizations you need only after your code is ready and you can do general profiling and decide what is worth the effort ...


0

I will not worry to much about performance here, but I will optimize the code a bit by calling get_post_meta() only once. This will not increase or decrease performance as you will see in the post I have linked to later on, but it comes down to the principle of not repeating yourself. On the contrary to what you are thinking, querying custom fields is ...


0

Import the database on the new server. When your domain name or URLs change there are additional concerns. The files and database can be moved, however references to the old domain name or location will remain in the database, and that can cause issues with links or theme display. If you do a search and replace on your entire database to change the URLs, ...


0

Import the database on the new server. When your domain name or URLs change there are additional concerns. The files and database can be moved, however references to the old domain name or location will remain in the database, and that can cause issues with links or theme display. If you do a search and replace on your entire database to change the URLs, ...


0

If you use those custom fields only for the company tagged posts, then it's sufficient to retrieve the custom fields without worrying about posts and tags: $tags = array('Professional Rating', 'Efficiency Rating', 'Referral Rating'); foreach ($tags as $tag) { $result = $wpdb->get_col( "SELECT meta_value FROM wp_postmeta WHERE meta_key = '$tag'" ); ...


1

Primary issue with your function is "get_template_part" internally use global $post variable to display the post fields. However, your $post variable is filled for this function only. I would suggest to read this handy article Displaying Posts Using a Custom Select Query Now, specifically in your case function lugaresincreibles_most_commented() { ...


4

It may be because group doesn't exist in the postmeta table. Your meta_key is probably called group and has a meta_value of bicyclegroup. This is assuming you haven't modified the postmeta table. What you could try is: $sql = "SELECT * FROM $wpdb->postmeta WHERE meta_key = 'group' AND meta_value='$group'"; This will return: meta_id post_id meta_key ( ...


2

You might be better off using the update_option_ action instead. This will allow you to write to your file after the option has been updated (as apposed to before). If another plugin hooks into pre_update_option_ and alters the value after your plugin has saved it then you will have saved an incorrect value. I would use: add_action( ...


0

You can set up another connection and use that database the same way you would interact with the WP database with $wpdb. This example creates an instance in $odb to be used the same as you would use $wpdb: global $odb; $args = array( 'user' => $database_user, 'pass' => $database_pass, 'name' => $database_name, 'host' ...


2

There is a filter exactly for that: pre_update_option_{option_name}. If the is option is, for example, names myoption, you could use somthing like this: add_filter( 'pre_update_option_myoption', function( $new_value, $old_value ) { //Do something before returning the new value to be saved in database return $new_value; }, 10, 2); Referene: ...


0

The easiest thing basedo n the information you provided would be to make Site A part of the Site B multisite network. Then your sites would definitely be sharing the same user table since it is one network. You can also look into domain mapping to make Site A have a totally different domain name from Site B and it's subdomains.


2

See Changing The Site URL « WordPress Codex for recovery instructions on how to reset the URLs without database access, i.e. by editing either the wp-config.php file or the theme's functions.php file with FTP: 1) by adding lines to wp-config.php (which can be left in place): define('WP_HOME','http://example.com'); define('WP_SITEURL','http://example.com'); ...


0

It is not doable if you want to keep around all wordpress features. Possible casualties of such configuration are search and RSS feeds, probably also category and author pages. If you go and actually create a new DB for each 1k posts then the game ends here as there is no simple way to share data between different databases. If you just want to create new ...


1

Is your plugin intended for use by others, or is it only going to be used on servers you control? If the latter, then there might be a few ways to achieve what you want. For instance, the Sync extension. With that, I think you could use a mutex or semaphore to set a flag, which you could then use in your read/write functions. If you already have memcache ...


0

How to fix it ? Go in SQL and write this code : UPDATE `wp2_usermeta` SET `meta_key` = REPLACE(`meta_key`, 'wp_', 'wp2_'); UPDATE `wp2_options` SET `option_name` = REPLACE(`option_name`, 'wp_', 'wp2_'); :)


1

Can you just tell me how I can grab the input value for "name" and add the entry to custom_post_type? Sure thing: if ( isset( $_POST['name'] ) ) { $name = sanitize_text_field( wp_unslash( $_POST['name'] ) ); if ( $name ) { wp_insert_post( array( 'post_title' => $name, 'post_type' => ...


0

user.php To modify usernames before a user is added, use the filter pre_user_login. Hope that helps.


0

The issue was one of mixed encoding. Some fields contained data encoded properly as UTF-8; others contained data encoded as something else, probably ISO-8859-1. When imported to a new UTF-8 database, this was causing truncation. My steps to solve this: Copy the original database, wordpress, to a new database, wordpress2. Make sure the collation of ...


0

A while ago I added a function to one of my sites to change a set of posts from one type to another. I can't remember exactly why, but I've dug it out and updated it a little, and it is tested and working. The function Place this in functions.php so that it can be called from anywhere within your blog. /** * Change the type of a WP_Post object * * ...


0

An alternative solution is to use WP REST API: http://wp-api.org/ If your custom post type uses custom fields, the RESP API saves you the trouble of including the custom fields in the RSS.


1

Well to say that these custom fields are insecure in the wp core tables is to say that the usernames and passwords are also insecure, along with any private or password protected posts. As long as you are not outputting these custom fields anywhere but a secure page for logged in, paid up users, no one could retrieve them without server side access to run a ...


0

This soluton will create a metabox on your Edit Post screen and show you four additional form fields - Name Position Publications Freetext It will then save the data in to a corrisponding DB table, with each field in it's own column as you specified. As you have not provided a table name I have guessed at wp_additional_post_info, but you can change that ...


0

It doesn't seem to be a WP Network main object for getting data from other sites in the Network i.e. $wp_network->site1->get_post_type('events'). I solved this using the automatically generated RSS feed for the custom post type. The feed is available on /[custom post slug]/feed How to read the data from other WP sites WP comes with SimplePie for easy RSS ...


0

Welcome to Wordpress development! There's a few things to answer about your question, the first is regarding the hanging on a blank page. Usually that means there is an error of some sort; one of the most helpful things you'll find during development is turning on Wordpress' DEBUG mode, which will instruct PHP to print out errors when anything goes wrong. ...



Top 50 recent answers are included