php - display custom plugin view on front end inside template body

EDITMay be my question is not well formedi need to use the url http:localhostwordpresshousesall-housesto display

EDIT

May be my question is not well formed i need to use the url http://localhost/wordpress/houses/all-houses to display a house plugin view somewhere in plugin directory

function getHouses(){
     include plugin_dir_path(__FILE__) . 'public/publicHouse.php';
}

the result i'm getting is on the picture below

I'm expecting the view with the whole template and houses view inside body template area

any help is appreciated

EDIT

May be my question is not well formed i need to use the url http://localhost/wordpress/houses/all-houses to display a house plugin view somewhere in plugin directory

function getHouses(){
     include plugin_dir_path(__FILE__) . 'public/publicHouse.php';
}

the result i'm getting is on the picture below

I'm expecting the view with the whole template and houses view inside body template area

any help is appreciated

Share Improve this question edited Sep 14, 2019 at 19:58 SHYAKA Rene asked Sep 14, 2019 at 8:15 SHYAKA ReneSHYAKA Rene 12 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

In your plugin class (e.g. MyPlugin), add public static function, returning some content:

public static function my_plugin_output() {
    // Build your content
    $output = '<div>';
    $output .= 'This is a text to display.';
    $output .= '</div>';
    return $output;
}

Once your plugin is activated, add this line to any template, you want the plugin content to appear:

<?php if (class_exists('MyPlugin')) echo MyPlugin::my_plugin_output(); ?>

@Frank P. Walentynowicz i dit it with fake post and it worked. on this link

wordpress fake post

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745146157a4613656.html

相关推荐

  • php - display custom plugin view on front end inside template body

    EDITMay be my question is not well formedi need to use the url http:localhostwordpresshousesall-housesto display

    3小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信