New answers tagged

0

if($search->keyword){ $project_args['s'] = $search->keyword; } That was the culprit. FML! Everything else was correct.


0

I just figured out myself how to do it Take a look at this example: $args = array(); $args['relation'] = 'OR'; foreach ( $tag_ids as $t ) { $args[] = array( 'key' => 'afz_entry_tags', 'value' => serialize( strval( $t->id ) ), 'compare' => 'LIKE' ); } $query->set( 'meta_query', $args ); I am getting ...


0

Ok, I solved this with a nice function, now the only thing left to do is to find a way to update all of the blog posts. doing this by hand will be really bad here is the code that I used add_action( 'save_post', 'myplugin_save_postdata' ); function myplugin_save_postdata( $post_id ) { if ( 'page' == $_POST['post_type'] ) { if ( ! current_user_can( ...


2

Probably the most "WordPress-y" approach to such a problem is to store the date of your 'event' custom post-type in the post's metadata. Enabling users to set meta-data on a post is usually accomplished by using the 'register_meta_box_cb' argument to the register_post_type() function to add an extra "meta box" interface to the pages for creating or editing a ...


0

Following the advanced example on https://www.advancedcustomfields.com/resources/date-picker/ this worked for me: <?php $current_header = ''; foreach ($posts as $post ) : setup_postdata($post); // get raw date: $date = get_field('event', false, false); // Get translated month and year of current post: $temp_header = date_i18n('F Y', ...


2

It's already in the docs. Try this: <?php $image = get_field('image'); if( !empty($image) ): ?> <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /> <?php endif; ?> For easier debugging, try this: var_dump($image); to print out the $image variable to know what is in $image. You can also put ...


0

Yes. You could keep other fields to specify the timestamp of the start and end dates. You then compare the timestamp on the front-end. If the current timestamp is larger than the start date and smaller than the end date, display the fields. Yes, kinda. I don't know if there's a straightforward way to do it, but you can probably write a function to ...


0

woa, you saved my day with this answer, i was trying to filter posts by custom numeric field called type_price and i was trying to do it that way: 'meta_query' => array( array( 'key' => 'type_price', 'value' => array( 0, 500000 ), 'compare' => 'BETWEEN', 'type' => 'NUMERIC', )), but it should be this way ...


0

You are just confusing the array levels, ordering is not done inside the meta_query level but on the main query level. It is the difference between two classes: https://codex.wordpress.org/Class_Reference/WP_Query https://codex.wordpress.org/Class_Reference/WP_Meta_Query Also, as the meta query codex says: "Custom field value can be an array only when ...


0

I would try it this way. Use a meta query to get your events list and load everything into a datatable. This seems like a perfect time to let visitiors filter and sort. Here's a simple implementtation (which may need tweaking). Just print or return the '$disp_data' variable from function call or in a template. If you don't have datatable set up I can help ...


1

Your best bet is not to run a bunch of queries but to loop through your data once to organize it then a second time to display it. Below is the logic you need. The exact code will depend on your data set. $events = array(); $posts = WP_Query( $args ); foreach ( $posts as $post ) { $venue = $post->venue; $day_of_month = date( 'd', $post->date ); ...



Top 50 recent answers are included