Hide posts if user is added to it WP_query

Hopefully i understood correctly what you want to achieve here. If you want to exclude all posts that contain get_current_user_id() in the project_users ACF repeater, but at the same time contains has get_current_user_id() in favourite_users, the correct meta query looks like this: ‘meta_query’ => array( ‘relation’ => ‘AND’, array( array( ‘key’ => ‘project_users’, ‘value’ => … Read more

Get ACF options field in PHP acting as CSS

I’m not sure what exactly your setup is or where this file is but ACF saves its values as post meta. So you could simply use WP’s get_post_meta() if ACF isn’t available. For Example: get_post_meta( get_the_ID(), ‘field_name’, true ); You can also have a look at this article, it talks about using get_post_meta vs ACF … Read more

Does get_post function counts as view?

WordPress doesn’t count post views. So no. Nothing counts as a post view. If you’re using a plugin or service that counts post views, then it would depend on that plugin or service, and how it measures views. You’d need to ask its author, but I feel safe saying that none of them would use … Read more

file_exists function does not work

file_exists() lets you check if a file exists on the local server, by passing it a file path. It cannot be used to check for the existence of files via URL, and you’re passing it the result of get_stylesheet_directory_uri(), which returns the URL (http:// etc.) to the file, not the path. The proper way, these … Read more

Show current user posts only

<?php $query = new WP_Query([ ‘author’ => get_current_user_id(), ]); while ( $query->have_posts() ) { $query->the_post(); the_title(); } wp_reset_postdata(); ?> In the example above we are using WP_Query look on the reference guide for additional parameters such as different post types like if you want to get only pages, posts or custom post types, as well … Read more

Custom Post type slider with thumbnail navigation

Follow this flow: Define an empty array $nav_img = array(); outside the loop. Inside the loop while you fetch the featured image, push the URL to the array too like this $nav_img[]=’your_image_here’ ; Then inside <div class=”slider-nav-thumbnails”></div> you can simply do a for each loop to set the images as thumb. UPDATE: Here I added … Read more

If Array Values Match Another Array’s Values, Then

Here’s one way to solve this: sort both arrays loop through them and compare them item by item (they should be equal, because arrays are sorted) . sort( $evaltypesReq ); sort( $evaltypesSch ); $containsAllValues = true; foreach ( $evaltypesReq as $k => $v ) { if ( $evaltypesSch[$k] !== $v ) $containsAllValues = false; }

How to access or parse key/values that have “string”

In it’s current state you would directly get the value from the associative PHP array by directly referencing the key like so: var_dump( $form_data[‘key’] ); It’s wise to note that when you dump variables using var_dump you get information on the value type, and length. So in this case you get string(33) which indicates the … Read more