Modify date query by URL parameter using pre_get_posts and $_GET

I’m not where I can test this, but for something like: www.website.com/events?date=past, perhaps an approach like that outlined below could work. (I can almost guarantee a type or two, so be sure to rewrite/edit/rework this into your function and ensure you don’t inherit my errors). if (isset($_GET[‘date’])) { //using past, present, future as example. not … Read more

Handling repeater data

Try: $fields = get_field(“updates_list”). And then print_r to see what’s inside. You should have a nice looking array with all repeater fields and values inside. Then, stop using have_rows and get_row and just loop using a foreach loop. get_field() is usually used to retrieve a unique field, but because it’s a repeater field you get … Read more

Display custom post type for specific user

try this: $args = array( ‘author’ => get_current_user_id(), ‘post_type’ => ‘YOUR_CUSTOMPOST_TYPE’, ); $author_posts = new WP_Query( $args ); if ($author_posts->have_posts()): while ($author_posts->have_posts()) : $author_posts->the_post(); //DISPLAY CONTENTS HERE endwhile; endif; wp_reset_postdata(); wp_reset_query(); replace YOUR_CUSTOMPOST_TYPE with your post type, what it does is finds posts of certain post type whose author is currently logged in user. Currently … Read more

How do I replace the post title with a custom field?

The acf/update_value filter won’t work as it’s meant for modifying the acf value and not the post it’s associated with. Try using the acf/save_post action instead. Here’s a simplified example of how I’d normally set the post title from first and last name fields in acf. add_action( ‘acf/save_post’, ‘biwp_set_title_from_first_last_name’, 20 ); function biwp_set_title_from_first_last_name( $post_id ) … Read more

Filter through custom taxonomy with an array of taxonomy IDs

First, you can’t enter such expression as second argument in get_term(). Enter directly the name of your taxonomy… Are you dealing with simple post categories? If that’s the case, your taxonomy name is ‘category’. $context[‘single_term’] = get_term( $user_terms_array[1], ‘category’ ); Second, ensure that $user_terms_array contains term IDs as integer. $user_terms_array = array_map( ‘intval’, explode( ‘-‘, … Read more

How do I get_the_postID() for a custom post that uses ACF repeater field?

From the plugin code I can see that it uses query_posts() to set up a new context for your template if you’re using display=”blah.php”. So you should just need to add the loop around your template: <?php /** * Template Name: Gallery */ while ( have_posts() ): the_post(); // <– Important bit if( have_rows( ‘card’ … Read more

Front-End User Profile

UPDATE: As mentioned in the comments, you might want to learn how you do things like create meta boxes and do a file upload in WordPress without using a framework like CMB2 first. However, as a seasoned WordPress developer, I have found that using CMB2 greatly increased my productivity. I highly recommend using CMB2 to … Read more

How to format custom fields when editing an attachment?

You’ll have to include and enqueue a new CSS file for your plugin on the admin side using admin_enqueue_scripts. And since you may want to load this on every page, I’d follow the first example on the Codex (pasted here): function load_custom_wp_admin_style() { wp_register_style( ‘custom_wp_admin_css’, get_template_directory_uri() . ‘/admin-style.css’, false, ‘1.0.0’ ); wp_enqueue_style( ‘custom_wp_admin_css’ ); } … Read more