How to extract images of post and pages excluding header and logo image in wordpress?

I believe this will get you all of your attachments: $q = new WP_Query( array( ‘post_type’=>’attachment’, ‘post_status’=>’inherit’ ) ); var_dump($q); You could further restrict that by adding other parameters, for example, ‘post_mime_type’ => ‘image’ would restrict only to images. That will return all images though, not just the ones attached to posts. What you want … Read more

Custom post type loop split/ordered by taxonomy

Check the below code- // Initiating shortcode. Place this code to any of your page to get your desired output. add_shortcode( ‘faq_page_content’, ‘the_dramatist_faq_page_content’); /** * Rendering function */ function the_dramatist_faq_page_content() { $terms = get_terms(‘sections’); // Taxonomy name echo ‘<ul>’; foreach($terms as $term) { $posts = get_posts( array( ‘post_type’ => ‘questions’, // Post type ‘tax_query’ => … Read more

Does using a custom query_var create a security hole?

Regardless of whether you registered new_var as a query_var, all GPC data (GET, POST, COOKIE) should be considered tainted. Basically, this data is user input. This means that you will need to clean and validate the data anyway. Common cleaning methods include casting the variable to a certain type (like integer or string), using a … Read more

Order by the results of a function with WP_query

@JasCav Here is something to put you in the right direction. Maybe someone can edit where needed. // args $args = [ ‘post_parent’ => $post->ID, ‘post_type’ => ‘page’, ‘posts_per_page’ => 8, ‘paged’ => get_query_var( ‘paged’ ), ‘meta_key’ => ‘team_school’, ‘meta_value’ => $school_type, ‘orderby’ => ‘wpse_last_word’, //<– make filter for ordering! ‘order’ => ‘ASC’ ]; // … Read more

Query Problem – Show posts within category ‘x’ that have a custom field between ‘y’ and ‘z’

May this code help $args = array( ‘cat’ => ‘Category id’ ‘post_type’ => ‘post type’, ‘meta_key’ => ‘enter your metakey’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ => ‘age’, ‘value’ => array(min price, max price), ‘compare’ => ‘IN’, ) ) ); $query = new WP_Query($args); $query will contain an Array of … Read more

Get number of comments after modifying comment query

Refrain from editing core files WordPress was developed with extensibility in mind, and provides many ways to change the appearance and functionality of an installation without altering the WordPress software itself (mostly using Hooks in conjunction with Plugins and Themes). The software is comprised of it’s “core files”, which are generally everything outside of the … Read more

Why does “get_option” pull in the older value in options.php, rather than the newer value, on submission of a form?

If your update_option call runs after you assign $posts1 and $posts2, then of course they’ll hold the “old” value, even if you sleep for eternity 😉 Either run the update earlier, or (re)assign the variables afterwards. $posts1 = get_option( ‘post1’ ); echo get_option( ‘post1’ ); // [my_id] echo $posts1; // [my_id] update_option( ‘post1’, ‘foobar’ ); … Read more