Hot answers tagged

4

Here's a little coding that should implement this for you: <?php $max_length = 5; // set max character length here $next = get_next_post()->ID; $prev = get_previous_post()->ID; if( $prev ) { $title = get_the_title( $prev ); $link = get_the_permalink( $prev ); $post_name = mb_strlen( $title ) > $max_length ? mb_substr( $title, 0, ...


2

WooCommerce is not the only plugin that will do this for you. Perhaps you want to take a look at this list of other options. If you think of building a cart on your own, don't think of it too lightly. Especially the interface to a payment option will be difficult. You may take inspiration from this code on github that implements a simple cart with paypal ...


2

No, wpdb::delete does not handle anything other than WHERE field = X. You can just use the query method instead: $ids = implode( ',', array_map( 'absint', $ids ) ); $wpdb->query( "DELETE FROM table_name WHERE ID IN($ids)" );


2

If I've understood your intentions correctly here, you don't need to use the meta_value argument at all. If you are just wanting to order by this meta_key but not filter which results are returned - i.e. you want to return the results from all the 'star' values - then providing the meta_key and the orderby arguments will get you there. There is no need for ...


2

There is no order_by. Change order_by to orderby and it should work. The default value of compare is = so it is unnecessary, you can remove it. Also, you should specify type of the meta_value if it is a specific type rather than the default CHAR.


2

After Milo's tutorship: I recommend first reading how to use AJAX in Plugins properly. – Milo yesterday and reading another questions on wp.stack, my problem was solved) Here is an examples of code from my rewritten files 1)get_state.php: ad add_action( 'wp_ajax_ajax_object', 'ajax_handler' ); add_action( 'wp_ajax_nopriv_ajax_object', ...


1

If you're trying to update the number stored in the meta table, you need to load that value and increment it. $count = get_post_meta( $bid_id, 'draftnumber', true ); if ( ! $count ) { $count = 1; // if the meta value isn't set, use 1 as a default } $count++; update_post_meta( $bid_id, 'draftnumber', $count ); References get_post_meta() ...


1

You could use wp_parse_id_list() to sanitize your comma seperated list of post IDs. It's defined as: function wp_parse_id_list( $list ) { if ( !is_array($list) ) $list = preg_split('/[\s,]+/', $list); return array_unique(array_map('absint', $list)); } where we can see that it returns unique array values as well. Note that absint() is ...


1

Change: the_post_thumbnail() To: the_post_thumbnail( array(50, 50) ); It's all documented on the codex / developer site at https://developer.wordpress.org/reference/functions/the_post_thumbnail/


1

Can't this be done by css? .nav_posts .title { display: inline-block; text-overflow: ellipsis; max-width: 30ex; white-space: nowrap; overflow: hidden; } <?php previous_post_link('<span class="nav_posts left">&larr; <span class="title">%link</span></span>'); next_post_link('<span class="nav_posts ...


1

If I get this right each of your posts have one value of Exercise and one Value of Tempo? I would do the following probably: Build a list of exercises. For each exercise query query: 1 posts, ordered by Tempo, descending. This is probably as good as it gets staying within realm of WP API. Might not be practical for high counts of Exercises, it's all ...


1

You first have to build a query for your posts, and inside that query you would get all your custom fields and compare them. You could use a plugin like CMB2 to build repeatble grouped fields so you can get the exercises grouped (all Excercises1, all Excercises2, etc) and also asign each to have a TEMPO field attached to that group. It would be easier then ...



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