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

Pagination hitting 404 page on /page/4

Just in case anyone ever stumbles across this, I found the solution. First step was to create an archive.php page In there I would access the loop. The in functions.php I have a category rewrite filter to update the category rewrite rules to use the following example url index.php?wpdmcategory=category-name&paged=2 when I hit /category-name/page/2 Previously, it … Read more