Get url from file uploaded in Media Library

If understand your question correctly, I think this can get the job done. Use get_attachment_link instead of wp_get_attachment_url and then echo the title. <?php $attachment_id = 2582; $attachment_page = get_attachment_link( $attachment_id ); ?> <a href=”https://wordpress.stackexchange.com/questions/255020/<?php echo $attachment_page; ?>”><?php echo get_the_title($attachment_id ); ?></a>

How to change “Publish” button text for specific page

I wanted to change the Publish button’s text in the Block Editor and came across this question. With the answers given it wasn’t changing the text. With the Gutenberg update, I realized it would have to be done with JavaScript. I found this response: Changing text within the Block Editor Which I applied in my … Read more

How to count media attachments?

Use this code if you’re in the loop: $attachments = get_children( array( ‘post_parent’ => $post->ID ) ); $count = count( $attachments ); If you’re not in the loop, substitute $post->ID with the ID of the specific post. But that should count all attachments.

How to get an image url from media library

You have to convert attachment variable to JSON object using toJSON() . Then you can its property. use attachment = frame.state().get(‘selection’).first().toJSON(); instead of attachment = frame.state().get(‘selection’).first();

Make attachment pages require a base url

Endpoints are for adding extra query vars to existing routes, I think you just want a vanilla rewrite rule here: function wpd_media_image_rewrite_rule() { add_rewrite_rule( ‘^image/([^/]*)/?’, ‘index.php?post_type=attachment&name=$matches[1]’, ‘top’ ); } add_action( ‘init’, ‘wpd_media_image_rewrite_rule’ ); You might want to loop over valid mime-types there and add a rule for each. You also need to flush rewrites for … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)