-= 1 =-
This is untested and might not work with your theme if it’s using a custom function to upload the actual images, but I would add the size you want using add_image_size( 'profile_photo', $width, $height, array( 'center', 'middle' ) );
to your functions.php
file.
Then you can retrieve the image using wp_get_attachment_image_src()
passing as the size
argument, your custom size name profile_photo
created with add_image_size()
.
As a side note, the wp_handle_upload_prefilter
filter only works in the admin area. So keep that in mind.
Also, I’m thinking that your theme might already be using add_image_size
for profile images, it might already be declared in your functions.php
file. Check it out as you might be able to adjust the size there already.
-= 2 =-
For your second question, again this is dependant on your setup but I would suggest you check out the found_posts
property of the WP_Query
object.
So you can build a query that looks for all your listings and echoes the found_posts
property for that query object, similar to
$args = array (
'post_type' => 'listings', // assuming your listing have their own post type
'post_per_page' => -1,
);
$my_query = new WP_Query( $args );
// Then print where you want
echo $my_query->found_posts;
of course you can modify your query to filter your posts by other arguments suiting your needs. Check out the WP_Query for all available arguments and properties.