WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Difference between revisions of "Function Reference/attachment url to postid"

(Description: add description)
(Usage: add usage example)
Line 9: Line 9:
   
 
== Usage ==
 
== Usage ==
%%% <?php ?> %%%
+
%%% <?php $attachment_id = attachment_url_to_postid( $image_url ); ?> %%%
   
 
==Example==
 
==Example==

Revision as of 19:24, 17 May 2013

Description

Retrieve the post id for an attachment file URL.

Parameters

$url
(string) (required) Permalink to check.
Default: None

Return

(int) 
Attachment ID if found, 0 if not.

Usage

 <?php $attachment_id attachment_url_to_postid$image_url ); ?> 

Example

Description text

Example code

Change Log

Source File

attachment_url_to_postid() is located in wp-whatever/file.php.

Related

Function ref links

This article is marked as in need of editing. You can help Codex by editing it.