R
R
rennameduser_34322021-08-10 17:08:26
WordPress
rennameduser_3432, 2021-08-10 17:08:26

How to display an image using a wordpress plugin?

<?php

/*
Plugin Name: WPM Image Holder
Plugin URI: https://wp-masters.com
Description: Set Thumbnail to All Posts where Image is not set
Author: WP Masters
Version: 1.0
*/

class ImageHolders {

  /**
     * Initialise functions
     */
    public function __construct()
    {
        // Put hooks here and look at the example how set function to hooks      
        add_filter( 'has_post_thumbnail', [$this,'check_post_is_has_thumbnail'], 10, 3 );
    }

  /**
     * Check Posts is has Image before Loop in FrontEnd
     */
    public function check_post_is_has_thumbnail($has_thumbnail, $post, $thumbnail_id)
    {      
        if($has_thumbnail == false) {
            
        }
        return true;
    }
}

new ImageHolders();


In this piece of code, I need to use some function that will set an image for the post that does not have it (by URL)
if($has_thumbnail == false) {
            
        }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question