Get posts associated with media attachment
A quick and easy way would be to just run a search on your WordPress site on the name of the image. E.g. your-image.png. This should return a list of all the posts which have that image in it.
A quick and easy way would be to just run a search on your WordPress site on the name of the image. E.g. your-image.png. This should return a list of all the posts which have that image in it.
Custom query for tag and custom tag from 2 post type
For those interested, i’ve solved my problem using sizeof($wp-query->posts) The end-result is this content-news.php template <?php //echo sizeof($wp_query->posts); //var_dump($wp_query);die(); if(sizeof($wp_query->posts) == 4) : ?> <?php if( $wp_query->current_post == 0 ) : ?> <h3><?php the_title(); ?></h3> <div class=”row”> <div class=”col-md-12″> <p><?php the_excerpt(); ?></p> <p><a href=”https://wordpress.stackexchange.com/questions/216989/<?php the_permalink(); ?>” class=”btn btn-primary btn-sm”>Lees Meer</a></p> </div> </div> <div class=”fh5co-spacer fh5co-spacer-sm”></div> … Read more
The best practice is the following: Put your Javascript code in a file, yourcustomjs.js, and store it in your theme folder. I would recommend yourtheme/js/yourcustomjs.js. Be sure that you wrap your script, where needed, in a Document.ready function like the following: jQuery(document).ready(function($) { // your code }); This enables you to ensure the $ shortcut … Read more
You can try the following: AND ($wpdb->postmeta.meta_key = ‘cc_price’ AND $wpdb->postmeta.meta_value LIKE ‘%$s_prc%’) (Use cc_price instead of $cc_price)
Change $data = get_post_meta(get_the_ID(),’_event_data’,true); to $data = get_post_meta(get_the_ID(),’_event_data’,false); As stated in the Code Reference, Return: (mixed) Will be an array if $single is false. Will be value of meta data field if $single is true. But somehow I’d just guess that _event_data doesn’t hold much more than the actual (event-) ID. You’d probably have to … Read more
Add the below code in your active theme’s functions.php file. function wpse_delete_query_transient( $post ) { // Deletes the transient when a new post is published delete_transient( ‘d_results’ ); } add_action( ‘new_to_publish’, ‘wpse_delete_query_transient’ ); This will delete the transient every time when a new post is published. If you want to delete the transients on differrent … Read more
Rewrite URL query string for all pages
I am not good at SQL but I believe this SQL query will do the job for you. UPDATE wp_posts SET post_status=”publish” WHERE post_type=”product” AND post_status=”trash”; Please remember to change WP database prefix if it is not default wp.
tag_slug__in should be an array, not a string, that is why your query fails ‘tag_slug__in’ => [‘featured’], // Requires PHP 5.4+, use array( ‘featured’ ) pre 5.4