Tag Info

Hot answers tagged

5

As the article mentions, using wp_options is not a good idea when you have thousands of terms, mainly because there's: a lot of serialization involved OR long option names (the limit is 64 characters) In this particular case, yes, it's appropriate to create some custom tables. To save time, you can use this plugin (update more recently than Simple Term ...


4

I think your question is a perfect example for the XY Problem. In WordPress you do not create such a menu in a post editor. You use a menu. Once you start thinking about your problem from this point, everything is easy. :) First register a custom navigation menu for this list in your theme’s functions.php: add_action( 'wp_loaded', ...


3

Ok, first of all, I feel like an idiot, although in my defense most of the articles that talk about this don't mention a very crutial detail in making this work. The answer is that you need to set permission for at least one admin in the database. This info can be found in the Codex here: ...


3

A convenient way to use $wpdb in plugins, with custom tables and custom functions is write a class or a couple of functions that get the wp object, and configure it. An example: /* Return global wpdb aready setup with custom tables */ my_plugin_get_db( wpdb $wpdb = NULL ) { static $db; if ( is_null($db) || ! is_null( $wpdb ) ) { $db = ...


2

That table is essentially the same as for all of the other "meta" tables in the WordPress architecture. It holds misc. bits of extra, usually optional, information about the associated post, user, or in this case comment. You can store whatever information you need to add to a comment-- perhaps a plugin wants to implement "abuse" flags, or comment upvotes. ...


2

Globalizing WordPress-defined vars is not the same as creating your own global variables. In the former, you have no choice, it's the latter which you can choose to avoid. Wrap your functions in a class and define your table name as a member var. This lets you define it in one place and keeps it out of the global scope.


2

DBDelta is extremely picky-- to the point of being maddening sometimes. From the Codex: You must put each field on its own line in your SQL statement. You must have two spaces between the words PRIMARY KEY and the definition of your primary key. You must use the key word KEY rather than its synonym INDEX and you must include at least one KEY. You must ...


2

Looking at this article on WP.org it seems you have to create your database first, with some SQL: function mp_install_table() { global $wpdb; $table_name = $wpdb->prefix . "countries"; $sql = "CREATE TABLE $table_name ( id mediumint(9) NOT NULL AUTO_INCREMENT, name tinytext NOT NULL, labour_cost INT, ...


2

Get all of your posts in one query, then count the iterations of your loop. Pseudo-code follows. if ( $query->have_posts() ) { $i = 0; while ( $query->have_posts() ) { // If $i is 5 (5th post), end one row and start the next if (++$i == 5) { echo '</tr><tr>'; } // the rest of your loop output


2

SELECT * FROM wp_posts, wp_2_posts, wp_3_posts WHERE wp_posts.post_content LIKE '%foo' OR wp_2_posts.post_content LIKE '%foo' OR wp_3_posts.post_content LIKE '%foo'; should do the trick. (Note that in Multisite, there shouldn't be a wp_1_posts -- your root site uses wp_posts etc.)


2

Here is what is happening with your code: query_posts uses the global variable wp_query. It always overwrites that variable, which is why you should not use query_posts pretty much ever. Your first query_posts clobbers the original $wp_query data. You start the Loop The first thing you do in that loop is reset $wp_query to the original query. Now the ...


2

This plugin does allow theming. Check out the "Other Notes" tab in the plugin page. As far as making it sortable, your path of least resistance is to use javascript. Here's a jQuery plugin that will do (almost) all the work for you. Hope that helps! Cheers~


2

The prepare() method escapes %s. The second piece of code you listed breaks because quotation marks are added to the table name, hence it doesn't match what's in the DB. The first piece of code works because it's a straight string replacement hence matching the name of the table in the database. What is the error message you are getting? HTH


2

WP-Table Reloaded is a great plugin which allows you to create tables and use their shortcodes in your post. Bear in mind, however, that not all themes are "table-friendly". Alternatively, you can try Dean's FCKeditor Plugin For WordPress, which appears to have an "Insert Table" function to keep you from messing around with HTML. And the best option, in my ...


2

The code you posted doesn't work because there is no global $currentpage. There are $current_screen and $pagenow. add_action( 'pre_get_posts', 'wpse_63414_hide_pages' ); function wpse_63414_hide_pages( $query ) { if( !is_admin() ) return $query; global $pagenow; $pages = array('2','26'); if( 'edit.php' == $pagenow ...


2

Please take a look at user_register hook This is fired when a new user is registered and conveniently passes you the user ID of the new user. function function_name( $user_id ) { /* do what you want to do with ID here */ } add_action( 'user_register', 'function_name');


2

Write a function that uses $wpdb->prefix as a fallback. Something like this: function wpse65880_table_with_prefix($table) { // should define array in config file, rather than hard coding $my_tables = array("table1", "table2", "table3", "table4"); if (in_array($table, $my_tables)) { // "qa_" should also be a config file setting ...


1

Shortcodes don't need to take the form [shortcodename attribute="val1,val2"], they can also take the form [shortcode]stuff,stuff2,stuff3[/shortcode]. You could use a plugin that makes use of such shortcode, such as this: http://wordpress.org/extend/plugins/easy-table/


1

Adding a BTREE or HASH index shouldn't break anything, and I imagine that is what you want. At worst you could end up with multiple indexes, or less than optimal ones, which might negatively effect performance. I assume that if you are going to do this you will be evaluating the change to see if it actually does help, rather than hurt. I guess you could ...


1

You're close, but not quite. Try it like this: function jb_applicant() { $custom_fields = get_post_custom(2171); $op = ''; foreach ( $custom_fields as $key => $value ) { $op .= $key . " => " . $value . "<br />"; } return $op; } add_shortcode('applicant', 'jb_applicant');


1

I did a quick Google search and it took me to this article. I have not used either of the plugins mentioned but they are TinyMCE Advanced and WP-Table Reloaded hopefully one of those work out for you.


1

Assuming you have table that's prefixed with the WordPress prefix (even if it's not the default one), and the table is called table. Then the following code should select everything, and allow you to go through each row. In this example, it goes through each row and outputs the content of the field foobar. global $wpdb; $results = ...


1

I don't have a plugin to point you to off the top of my head, but my general suggestion is this: Store the relevant plugin settings in a single option, as an array. The crux of the reasoning here is that you're just adding items to a single array, which is auto-keyed, so you can add or subtract at will, without worrying about naming. In practice, this means ...


1

The wp_bp_xprofile_data table holds all of the custom fields used on the front-end by BuddyPress. It is independent of the WordPress user meta. All of the functions that interact with this table can be found in bp-xprofile/bp-xprofile-functions.php.


1

The issue is that you are using an extremely unique configuration: It is called Maya Shop. We are also using the Woo Commerce plug in for the remaining e-commerce functions. Two e-commerce platforms? Considering the uniqueness and the fact that you already have a developer on this project: This question is very unlikely to apply to anyone else. ...


1

Perhaps there's a manageable way to shift the images from being store as attachments (aka posts) to being stored in an array that's kept at the parent post level. I think it's going to depend on how much you need to manipulate the images, delete them, etc. Shifting to another table might help but it would seem to me you might be robbing Peter to pay Paul. ...


1

The two variables $name and $email are unknown inside the function. You have to make them globally available inside it by changing global $wpdb into global $wpdb, $name, $email: require_once('../../../wp-load.php'); /** * After t f's comment about putting global before the variable. * Not necessary (http://php.net/manual/en/language.variables.scope.php) ...


1

Yes, this is the correct behavior, and no, there is nothing you can do about it in a multi-site setup. But that's usually not a problem; disk space is cheap. Maybe you could run a workaround with a single-site installation and rewrite rules to map subdomains to URLs like /author/post-name/. But that sounds like a collsion magnet; so I wouldn't recommend it. ...


1

to_ping is a list of URLs WordPress should send pingbacks to. pinged is a list of URLs WordPress has sent pingbacks to. Do not use these fields for something else. They are parsed many times in core code (69 matches for to_ping); their format is fixed. You cannot reduce the query load by using these fields, because all post meta fields are fetched in ...


1

dbDelta is extremely picky. Looking at your code I'd say you've violated this rule: You must put each field on its own line in your SQL statement Two of your fields are sharing lines with parenthesis. I haven't tested that particular pattern but dbDelta is extremely picky. I don't know if that space after NOT NULL will matter. I doubt that checking ...



Only top voted, non community-wiki answers of a minimum length are eligible