How to add a media with PHP

If I’m understanding correctly, each post has a filemaker, and each filemaker has only one photo? The structure is kind of unclear. Anyways, one way is top use media_sideload_image like below. However, media_sideload_image WON’T work with local files (a path on your filesystem), so you need to change your $file[‘url’] to be a valid URL … Read more

get attributes/part of the gallery shortcode

The task It’s not as easy, as it looks at a first glance. The main problem is, that you can define your own shortcode and simply override the default. Actually that’s what some themes are doing (blame you ThemeForest authors!). In this case, simply hooking into post_gallery won’t work in every case. Drawbacks for post_gallery … Read more

Edit image preview is not displayed

By default, wp-config.php might not have a closing tag ?> and this is acceptable and by design. The issue may arise from whitespace in some other .php file. In my case, I had whitespace after the closing tag of my functions.php file for my child theme. Once I removed that whitespace, the images are showing … Read more

unable to upload image locally

You need to change the file permissions on your wp-content folder (and containing folders) to 755. On your setup you can do this with: find . -type d -exec sudo chmod 755 {} \; Please note that using chmod -R 755 will mark both directories and files as 755.

How do I add a featured image to a single post page?

In single.php, find <?php the_content(); ?> around line ~17. Just before that. paste following code. <?php if ( has_post_thumbnail() ):?> <div class=”featured-image-wrap”><?php the_post_thumbnail(); ?></div> <?php endif; ?> This will show featured image if assigned to the post. To change the size of image you can pass parameter to the function the_post_thumbnail(). See official documentation of … Read more

Find posts without featured image? [duplicate]

You can use this plugin https://wordpress.org/plugins/quick-featured-images/ In description it says “You can also see posts with no featured image at a glance.” But from code side, wordpress manages images, documents any media by creating an attachment post for holding the information about that media and it’s relation (if any) with other post/posts, which means you … Read more

Setup A Default Featured Image

One simple method is to filter post_thumbnail_html, to add in a default image link: <?php function wpse55748_filter_post_thumbnail_html( $html ) { // If there is no post thumbnail, // Return a default image if ( ” == $html ) { return ‘<img src=”‘ . get_template_directory_uri() . ‘/images/default-thumbnail.png” width=”150px” height=”100px” class=”image-size-name” />’; } // Else, return the … Read more

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