You need to create block, template and layout files for this. Create a new file app\code\Your_ExtensionName\Your_ModuleName\Block\Post.php
<?php
namespace Your_ExtensionName\Your_ModuleName\Block;
use Magento\Framework\View\Element\Template;
class Post extends Template
{
protected $mymodulemodelFactory;
public function __construct(
Template\Context $context,
\Your_ExtensionName\Your_ModuleName\Model\ResourceModel\Post\CollectionFactory $mymodulemodelFactory,
array $data = []
) {
parent::__construct($context, $data);
$this->mymodulemodelFactory = $mymodulemodelFactory;
$this->_isScopePrivate = true;
}
public function getPosts(){
$collection = $this->mymodulemodelFactory->create();
return $collection;
}
}
Now create layout file app\code\Your_ExtensionName\Your_ModuleName\view\frontend\layout\Your_ModuleName_index_index.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Your_ExtensionName\Your_ModuleName\Block\Post" name="posts" template="Your_ExtensionName_Your_ModuleName::post.phtml">
</block>
</referenceContainer>
</body>
</page>
Now create app\code\Your_ExtensionName\Your_ModuleName\view\frontend\templates\post.phtml
<?php $collection = $this->getPosts(); ?>
<div class="yourtable">
<?php foreach ($collection as $item){ ?>
<div class="yourtable">
<?php
// Display your data
?>
</div>
<?php } ?>
</div>