[wp-trac] [WordPress Trac] #32275: get_page_by_title could return an array with all the matches
WordPress Trac
noreply at wordpress.org
Thu May 7 16:42:53 UTC 2015
#32275: get_page_by_title could return an array with all the matches
-------------------------+-----------------------
Reporter: brgweb | Owner:
Type: enhancement | Status: closed
Priority: normal | Milestone:
Component: Query | Version: 4.2.1
Severity: normal | Resolution: invalid
Keywords: close | Focuses: template
-------------------------+-----------------------
Changes (by boonebgorges):
* status: new => closed
* resolution: => invalid
* milestone: Awaiting Review =>
Comment:
> Thank you for your comment. It's my first time here in core development.
Thanks for the ticket, and welcome :)
> The problem I've found here was that I needed to query attachments with
the same original filename. Since the filename is changed in the upload
and the post-name is changed too, both to prevent duplicates, the easiest
way to find it was querying by post_title (assuming that the user didn't
change it after upload).
Gotcha. I guess the issue of '-x' is why you can't query against
'_wp_attached_file' postmeta? WP doesn't store an unmodified version of
the filename anywhere that I can see. If you need it, I'd suggest hooking
into the file upload process somewhere - maybe at 'wp_handle_upload'? -
and storing it yourself, in a way that'll be easy to query.
Using 'post_title' to look this up is, IMO, a fragile hack, but that
doesn't mean that fetching multiple items by 'post_title' doesn't have
relevant use cases. That being said, I do think it's better suited as an
improvement for `WP_Query` than here. If you think this is worth pursuing,
please feel free to open a separate enhancement ticket.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/32275#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list