Tag Info

New answers tagged

0

There is a beautiful tutorial vailable at http://shibashake.com/wordpress-theme/expand-the-wordpress-quick-edit-menu


0

There is no comment_ID until you are in the foreach loop. Try: $comments = get_comments($args); foreach($comments as $comment) : echo '<div id="' . $comment->comment_ID . '">Agent Name ' . $comment->comment_author . 'Phone' . $comment->comment_phone . 'Reply' . $comment->comment_content . '</div>'; echo get_comment_meta( ...


0

There are a couple of ways to do it. Try: <?php if ( get_post_meta($post->ID, 'author-photo', 'author-name', 'author-bio', true) ) { ?> <div class="authorbox"> <div class="authorphoto"> <img src="<?php $key="author-photo"; echo get_post_meta($post->ID, $key, true); ?>" /> </div> ...


0

Create a Page_YourCustomName.php . copy page.php content to your new file. add the following code to first Line : <?php /* Template Name: Your Custom Name */ ?> Once you upload the file to your theme’s folder , go to the Page > Edit screen in your admin dashboard. On the right hand side under attributes you’ll see template. This is where users are ...


1

Plugins that load the WordPress environment this way get rejected from the repository, as they are prone to failure in non-standard configurations. For something like this I would use the admin-post-$action to receive requests. The WordPress API will be available where you can check if users are authorized to perform specific actions.


0

After adding our custom column, we are ready to expand our Post Quick Edit menu using the quick_edit_custom_box action hook. Note – The quick_edit_custom_box action hook will not fire unless there are custom columns present. That is why we started by adding a custom column. add_action('quick_edit_custom_box', 'shiba_add_quick_edit', 10, 2); function ...


0

You can use the the acf/save_post action to copy the content from your custom 'full_text' field over to the normal post content field, so it can automatically be accessed by toc+ and other plugins. add_action( 'acf/save_post', 'wpse199256', 20 ); function wpse199256( $post_ID ) { global $wpdb; $post = get_post( $post_ID ); $wpdb->update( ...


1

If you wanna show or hide entire meta box when event date is change, you can try to use Conditional Logic plugin, so you can rewrite your code like so: $meta_boxes[] = array( 'id' => 'wr_event_review', 'title' => 'Event Review', 'pages' => array( 'wr_event', ), // Post type 'context' => 'normal', ...


0

Try this.... <?php $string = get_field('first_name'); echo $string[0]; ?> I am not that much familiar with ACF. But my answer is based on their function reference here http://www.advancedcustomfields.com/resources/the_field/ Hope this helps. Sabbir H


0

This isn't really a WordPress question, but since you're using the Loop, a lot of people will assume it's WordPress-specific. That being said, the solution is to use PHP's native array-to-string conversion utilities. Instead of the code you do have, you'll want to use something like: <?php $posts = get_field( 'author_name' ); if ( $posts ) { echo ...


0

The answer is simple: do not use sanitize_html_class. Take the input as it is (you can still do basic validation like length, making sure it is an integer only etc) and if you need to output that on the front and you don't trust the user who stored the data either use something like esc_html or wp_strip_all_tags depending on your needs. Of course, you can ...


0

Simply you need to replace the_field('video') with get_field('video'). Why? Because according to ACF documentation; get_field($field_name, $post_id, $format_value) Returns the value of the specified field. Whereas on the other hand the_field($field_name, $post_id) Displays the value of the specified field. (this is the same as “echo ...


0

Yes, custom fields or meta fields are part of WordPress. There are all information you need.


0

get_queried_object_ID() will return the ID on the page for posts, or get_queried_object() will return the page object containing all its post fields. Alternately, the ID of the blog page is stored in the option page_for_posts, which is internally how get_queried_object gets the ID of the post object to load.


1

Use tis plugin https://wordpress.org/plugins/acategory-dropdown-list/ It may be help you


0

Not entirely sure, but looks like Wordpress doesn't have a method to update custom fields in batches, so, 1 query to the DB per field.


0

Solved the issue by passing the term_name as a parameter to the callback function to the filter. function bn_term_title( $term_name ) { $term_types = get_term_by( 'name', $term_name, 'tax_1' ); if( $term_types->taxonomy === 'tax_1' ) { if( get_locale() === 'bn_BD' ) return get_term_meta( $term_types->term_id, 'tax1_bn' ); ...


0

few ways to do this task. Here i used to follow this code. $update_post = array( 'ID' => $id, 'post_status' => 'private', 'post_type' => 'job' ); wp_update_post($update_post); Take a look at here for more info. Read Here Kvcodes.com


0

You are abusing pre_get_posts badly with that code. With pre_get_posts the point is to alter the main query. By doing that you reduce the number of necessary queries and save some processing time, plus keep the WordPress globals-- $wp_query, for example-- neat for any other code that might need them. What you are doing is creating new globals and populating ...


4

I know this post is old, but to keep this question updated: As of WooCommerce 2.4.4 woocommerce_process_product_meta_variable no longer works, and it must be changed to woocommerce_save_product_variation So, Change: add_action( 'woocommerce_process_product_meta_variable', 'save_variable_fields', 10, 1 ); Into: add_action( ...


0

Ok I got it working. Not sure what I had wrong first time around but I just copied the first function and replaced order with user. Also included the code to display the field in user profile for reference. function save_passport_to_user_meta( $user_id, $posted ){ // don't forget appropriate sanitization if you are using a different field type ...


1

Order by the last word in the post title To order by the speaker's last name, you can use the following setup (PHP 5.4+): // args $args = [ 'posts_per_page' => 10, 'post_type' => 'speaker', 'meta_key' => 'speaker-front-page', 'meta_value' => '1', 'orderby' => 'wpse_last_word', ...


0

You can simply update the usermeta just after or before update_post_meta in your code as follows if(is_user_logged_in()){ $user_id = get_current_user_id(); //will work only if the user is logged in (to make sure user login, you can disable guest checkout from WooCommerce settings) update_user_meta( $user_id, '_passport_field', ...


0

Got it - just use this: <?php $query = new WP_Query( array( 'tag__in' => $tags ) ); ?>


0

The question is from a long time ago but, just for reference, in this particular case and if somebody simply wants to use the checked function with what seems to be an array (instead of doing the test and output 'checked` on the spot) here is a drop-in solution: checked( in_array( $shopCategory->term_id, $term_meta['ss_aff_categories'] ) ) This works ...


1

Try logging out of the site and going to /wp-admin (to get to the login screen). Click on the Forgot Password link and enter your username. Did you get an email with password reset instructions? If not, that means that the email configuration (as Emetrop has suggested) may not be correct for the server.


0

Your code looks good. I'd bet with you that it's a problem with configuration of email sending server. Maybe you haven't configured sendmail on your hosting. You can make it works easily if you send emails via a SMTP server (ie. gmail). You can do it easily with WP Mail SMTP plugin. Or just write to your hosting provider to make it working.


0

I assume that you want to add more custom fields in widget back end form, for this you just need to create a new field in form( $instance ); function. So the code will look like // Widget Backend public function form( $instance ) { if ( isset( $instance[ 'title' ] ) ) { $title = $instance[ 'title' ]; ...


0

After some practice, I found two ways to do this prettier: As a text widget: You just have to define a widget area in your template. After this, in Appearance>Widget, you can add a "Text" widget in this area, with any free HTML code. It can do the trick for the ones who write HTML As a settings page: Thanks @czerspalace for your answer ! The solution can ...


0

Building on Phil's answer: Made the following change to the switch: case 'extranet_sort_document_case': add_filter('posts_join', 'extranet_clientdocument_case_join'); add_filter('posts_fields', 'extranet_clientdocument_case_fields'); add_filter('posts_orderby', 'extranet_clientdocument_case_order'); break; and wrote the following functions: function ...


1

(I was going to add this as a comment as it's not a full answer, but I can't yet...) I think you will need to use an SQL query as the standard meta_queries / orderby won't work. Have a look at Custom Table Column Sortable by Taxonomy Query and http://wpdreamer.com/2014/04/how-to-make-your-wordpress-admin-columns-sortable/#sorting-posts-option-b for a couple ...


3

Just use do_shortcode: echo '<div class="wrap">'. do_shortcode( $two ) .'</div>';


0

You want to use body_class filter. function prefix_add_body_class( $classes ) { global $post; // good to check if( ! is_single() || 'post' !== get_post_type() ) { return $classes; } $btag = get_post_meta( $post->ID, 'tagbody', true ); if ( empty( $btag ) ) { return $classes; } $classes[] = $btag; ...


0

Try var_dump(get_user_meta($user->ID, 'wpcf-team-experience-member-type'), true). The third parameter for get_user_meta (called $single) specifies whether to return a single value (true) or an array (false). The default is false.


0

The reason you get the "First" Array is that you don't use the "single" option of the get_user_meta function. Try this: $arr = get_user_meta($user->ID, 'wpcf-team-experience-member-type',true); $options = array(); if(is_array($arr)){ foreach($arr as $key => $value){ foreach($value as $arrvalue){ $options[] = $arrvalue; ...


0

The array is just contain another array that contains the array where the 'student' is located. You can use array_keys() to return all the keys or a subset of the keys of the array and access the string 'student' with integer keys instead of an int-string-int [0]["wpcf-fields-checkboxes-option-f4fe375f6cad3c44eff97e6e6f16deb2-1"][0], like this: $arr = ...


4

If you don't feel any performance degradation then there is no problem. If it took you two years to get to this state then you probably safe for another two years, which is almost forever in the time scale of the internet (unless you are CNN or similar). This doesn't mean that you should not try and save space wherever it is easy to do. Do you really need ...


0

The hook you choose is important here. I found success choosing the latest hook I could wp_insert_post. If other functions are hooked to the same action they need to be considered because if they create/update posts too these hooks will be called again. The codex lists the Post, Page, Attachment, and Category Actions (Admin) in sequence. Working code for ...


2

You can achive this using WP Query with meta_query argument as following. $args = array ( 'post_type' => array( 'post' ), // YOUR POST TYPE 'meta_query' => array( array( 'key' => 'country', 'value' => $your_country, // THE COUNTRY TO SEARCH 'compare' ...


2

When executing the generated SQL statement in MySQL it gave me The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay To fix that I had to call $wpdb->query( 'SET OPTION SQL_BIG_SELECTS = 1' ); right before calling WP_User_Query.


0

//Your color codes $str1 = "000000 f0f0f0 c0c0c0 202020 404040 "; $str2 = "0000ee 555333 cc0000 602040 003399 "; $str3 = "9999cc 0000cc 0099ff 204010 552299 "; $str4 = "406040 ffffff ffcccc 000000 202020 "; $str5 = "cc0000 99ffcc cc9900 ff9999 000000 "; //creating an array and merging all codes ...


0

Assuming you are using post_meta this should help:: $color = 'red'; $the_query = new WP_Query(array( 'meta_key' => 'color', 'meta_value' => $color ));



Top 50 recent answers are included