JK Patel
JK Patel

Reputation: 858

plugin on subpage required resource in subpage's directory

resource Means (assets, image, icon and all misc)

i make a plugin which required a resource in wordpress\wp-content\plugins\Hope_widget when it is placed in home page, but when i set it in sub page then it required resource from its subpage's url. so fire me a error like 'Failed to load resource: the server responded with a status of 404 (Not Found) '

Example

subpage have link say http://www.asdasd.com/itsTest then resource found http://www.asdasd.com/itsTest/wp-content/plugins/Hope_widget but it should be http://www.asdasd.com/wp-content/plugins/Hope_widget

Please help me if you have some idea!!!

Upvotes: 0

Views: 33

Answers (1)

Howli
Howli

Reputation: 12469

From the WordPress plugin reference, using:

<?php
echo '<img src="' . plugins_url( 'images/wordpress.png' , __FILE__ ) . '" > ';
?>

should output:

<img src="http://www.example.com/wp-content/plugins/my-plugin/images/wordpress.png">.

Removing the image tag and entering your required tag around it should fix your problem.

Upvotes: 1

Related Questions