How to convert custom field value to tag

Since this is a one-time task, it’s easiest to create a migration script like so. Note: It might timeout (trying to process 90k rows) depending on how much memory your server has. function my_migration_script() { global $wpdb; // Quick and dirty way to get post ids. Normally don’t use this method. $post_ids = $wpdb->get_col( “SELECT … Read more

Don’t display html if custom field is empty

I have no experience with WP UI, but the following code might do the trick: <!– Videos Tab –> <h3 class=”wp-tab-title”>Videos</h3> <?php if (get_field(‘videos’) && get_field(‘videos’) != “”) { ?> <div class=”wp-tab-content”> <?php the_field(‘videos’); ?> </div><!– Close Videos –> <?php } ?>

Custom fields won’t display on my blog page

Try using: <?php // Determine context $page_id = ( ‘page’ == get_option( ‘show_on_front’ ) ? get_option( ‘page_for_posts’ ) : get_the_ID ); // Echo post meta for $page_id echo get_post_meta( $page_id, ‘Page Description’, true ); ?> What’s happening: You’re using a static page as front page, and a static page to display the blog posts index … Read more

Show User Their Password

Theoretically, this could be achieved by saving a user’s password elsewhere, when he or she updates it. Note that this sort of thing is hardly ever recommendable. In almost all cases, there is a better architectural approach that renders having to be able to show plain-text passwords unnecessary. That being said, if you absolutely must … Read more

Populating meta box with select-list of existing posts, and assigning it to custom post types

I believe this is what you were looking for. I moved back to using a class because what you were using would very easily conflict with someone else’s code who decided to use the function names select_box_add_meta_box(), select_box_content() and/or select_box_save_postdata(), which is reasonably likely. The class name WPSE_85107 is only likely to conflict with somebody … Read more

Order by custom field date with ASC order

With some more googling: <?php $today = date(“Y/m/j”); query_posts(array( ‘post_type’ => ‘custompost’, ‘posts_per_page’ => 4, ‘meta_key’ => ‘mydate’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ => ‘mydate’, ‘meta-value’ => $value, ‘value’ => $today, ‘compare’ => ‘>=’, ‘type’ => ‘CHAR’ ) ) )); if (have_posts()) : while (have_posts()) : the_post(); ?> <a … Read more

can you set a default value to a custom field

You can check it by adding a hook to save_post action. In this way all your posts will have default value for a custom field. add_action( ‘save_post’, ‘wpse8170_save_post’, 10, 2 ); function wpse8170_save_post( $post_id, WP_Post $post ) { if ( ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) || !current_user_can( ‘edit_post’ ) ) { return; } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)