Query values from a Post Object Repeater [closed]

Try this alternative way of getting the post objects. Seeing as your loop seems to be using the global post data anyway, this method uses setup_postdata to set the global values. $post_objects = get_field(‘post_objects’); if( $post_objects ): ?> <ul> <?php foreach( $post_objects as $post): // variable must be called $post (IMPORTANT) ?> <?php setup_postdata($post); ?> … Read more

How to return another post than requested

If you can access the ID of your post, it means that the query has already been run. So, in this case, you can’t use pre_get_posts anymore. A solution would be to wrap your code in a conditional, and then use functions such as get_the_permalink() or get_the_title() which accept a post ID, to get the … Read more

Posts list in custom taxonomy

$term isn’t being set anywhere in your code. You’re putting IDs into $terms_ids, but then in your query you’re using $term->term_id. $term doesn’t exist outside of the foreach. You need to be passing $terms_ids directly into terms: $terms = get_the_terms( get_the_ID(), ‘kosmetyki_dystrybutor’); $terms_ids = []; foreach ( $terms as $term ) { $terms_ids[] = $term->term_id; … Read more

Append class to posts page

In your theme’s functions file, use the body_class filter to add new classes: function wpse_282694_body_class( $classes ) { if ( is_home() ) { $classes[] = ‘blog’; } return $classes; } add_filter( ‘body_class’, ‘wpse_282694_body_class’ ); If your category archives, tag archives, date archives and search results also need the same styling, which is fairly commin, check … Read more

Update Modified date when scheduled posts get published

With the help of someone else, I managed to figure this out. Add this to your functions.php: // Scheduled posts should update modified date when published function update_modified_date_to_post_date( $post ) { $updated_data = [ ‘ID’ => $post->ID, ‘post_modified’ => $post->post_date, ‘post_modified_gmt’ => $post->post_date_gmt ]; wp_update_post( $updated_data ); } add_action( ‘future_to_publish’, ‘update_modified_date_to_post_date’, 10, 1 );