Verified working:
- name: Delete sample page
shell: "wp post delete --allow-root $(wp post list --allow-root --post_type=page --posts_per_page=1 --post_status=publish --pagename=\"sample-page\" --field=ID --format=ids)"
args:
chdir: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/"
with_dict: "{{ wordpress_sites }}"
See method #3 here on the best way to test this (best way imho anyway).