How to only display all posts to a custom User Role?
How to only display all posts to a custom User Role?
How to only display all posts to a custom User Role?
Display category filters for custom post type when category is shared by multiple post types
Below is the updated code to fetch posts, please check is that helpful: $documents = get_posts(array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘our_people_author’, // name of custom field ‘value’ => ‘”‘ . get_the_ID() . ‘”‘, // matches exaclty “123”, not just 123. This prevents a match for “1234” ‘compare’ … Read more
The following code should return you the correct category names, however I am not clear what you’re actually trying to achieve. I think you’re using the foreach loop in wrong way. Are you trying to add all the category names as css classes for the div or something else? <div class=”row masonary-wrap”> <?php $args = … Read more
Define multiple prefixes for custom post type
Ok, found the (a?) solution. “rewrite” => array( “slug” => “activity”, “with_front” => false ), and function my_injecter_agence_in_activite_url( $post_link, $id = 0 ) { $post = get_post( $id ); if ( $post->post_type == ‘activity’ || ‘publish’ == $post->post_status ) { $terms = wp_get_object_terms( $post->ID, ‘agence’ ); if ( $terms ) { $post_link = str_replace(“activity”, $terms[0]->slug.’/activite’, … Read more
What I would suggest is to create a custom WP_Query. What you would do is something like this (modified from ACF documentation): <?php $posts = get_posts( array( ‘meta_query’ => array( array( ‘key’ => ‘in_row_view’, ‘value’ => ‘1’, ) ) ) ); if( $posts ) { foreach( $posts as $post ) { // Do something. } … Read more
I manage to filter the posts, this seems to be enough for this project function remove_notallowed_authors( $query ) { $user = wp_get_current_user(); if ( in_array( ‘editor_group_role’, (array) $user->roles ) ) { $user_ids = get_users( [ ‘role’ => ‘user_role_that_posted’, ‘fields’ => ‘ID’ ] ); $query->set( ‘author__in’, $user_ids ); } } add_action( ‘pre_get_posts’, ‘remove_notallowed_authors’ );
background featured image display using shortcode
Ok, so after another hours of digging through the codex, I found a solution. Hope this helps anyone else who is runs into the same issue. I had to use the register_taxonomy_for_object_type function. And then I used the init hook. Here is the function that worked for me. function add_cpt_to_project_tax(){ register_taxonomy_for_object_type(‘project_category’, ‘external_project’); register_taxonomy_for_object_type(‘project_tag’, ‘external_project’); } … Read more