Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This can be very easy depending on your skills. I expect a downvote on your question but I will briefly run through the steps since this is not the way SO works. The first thing is to edit our THEMES files. Since OpenCart is MVC, we edit our Theme and then our PHP... or PHP and then the THEME files.. this is vice versa..</p> <h1>Guide</h1> <p>1 - Open <code>/catalog/view/theme/default/template/common/home.tpl</code></p> <p>After this line:</p> <pre><code>&lt;h1 style="display: none;"&gt;&lt;?php echo $heading_title; ?&gt;&lt;/h1&gt; </code></pre> <p>Add this:</p> <pre><code>&lt;?php MyWordPressFunction() ?&gt; </code></pre> <p>or this:</p> <pre><code>&lt;div&gt; &lt;h2&gt;Latest posts from our blog&lt;/h2&gt; &lt;?php MyWordPressFunction() ?&gt; &lt;/div&gt; </code></pre> <p>2 - Open our PHP code which is now the code for the <code>home.tpl</code> page, this is <code>/catalog/controller/common/home.php</code></p> <p>At the bottom of the code after the main class and the ending <code>?&gt;</code> PHP tag add this:</p> <pre><code>// WORDPRESS LATEST POSTS //#customPHP // The tag above is so that when you upgrade OpenCart // Before doing so you need to make sure of all the core // core changes you made - a unique global comment tag // is easy to find. function MyWordPressFunction(){ // DB // GET THE POSTS // LIMIT BY 5 // ORDER BY LATEST POSTS $sql=mysql_query("SELECT * FROM `wordpress_db`.`wp_posts` ORDER BY `wp_posts`.`post_date` DESC LIMIT 5"); while($row = mysql_fetch_array($sql)){ // VARS (easy to play with in the echo) $id=$row["ID"]; $author=$row["post_author"]; $date=$row["post_date"]; $post=$row["post_content"]; $title=$row["post_title"]; echo ' &lt;div id="postID_'.$id.'&gt; &lt;h3&gt;'.$title.'&lt;/h3&gt; &lt;p&gt;'.$post.'&lt;/p&gt; &lt;p&gt;Posted by '.$author.' on '.$date.'&lt;/p&gt; &lt;/div&gt; '; } // END DB } </code></pre> <p>That should give you an idea of some basic PHP function calls. It is a direction to get you started. You can further expand to link categories, author links, etc..</p> <p>By the way, all these variables can be used as you can see in the WP_Posts table:</p> <pre><code>/* All these can be used ID post_author post_date post_date_gmt post_content post_title post_excerpt post_status comment_status ping_status post_password post_name to_ping pinged post_modified post_modified_gmt post_content_filtered post_parent guid menu_order post_type post_mime_type comment_count */ </code></pre> <h1>Tips</h1> <p>Generally look through the entire OpenCart filter on SO - there are many articles on writing mods, modifying how it works and creating custom pages - these will really help in your long time tweaking. The above code is not got styling or further tweaks, this is a guide.</p> <h1>Further reading and better module type posts</h1> <p><strong>How to add new module to opencart administration?</strong></p> <p><a href="https://stackoverflow.com/questions/10971817/how-to-add-new-module-to-opencart-administration/10981636#10981636">How to add new module to opencart administration?</a></p> <p><strong>How to create a custom admin page in opencart?</strong></p> <p><a href="https://stackoverflow.com/questions/10700761/how-to-create-a-custom-admin-page-in-opencart/10701414#10701414">How to create a custom admin page in opencart?</a></p> <p><strong>How do I get an external page coupon/voucher form to work in OpenCart?</strong></p> <p><a href="https://stackoverflow.com/questions/12280666/how-do-i-get-an-external-page-coupon-voucher-form-to-work-in-opencart">How do I get an external page coupon/voucher form to work in OpenCart?</a></p> <p><strong>Opencart - How I can execute a custom code on product page? Without mods on controller product</strong></p> <p><a href="https://stackoverflow.com/questions/11847785/opencart-how-i-can-execute-a-custom-code-on-product-page-without-mods-on-cont/11854987#11854987">Opencart - How I can execute a custom code on product page? Without mods on controller product</a></p> <p><strong>How can I display the SubTotal on OpenCart on any page?</strong> </p> <p><a href="https://stackoverflow.com/questions/12095789/how-can-i-display-the-subtotal-on-opencart-on-any-page-i-wa">How can I display the SubTotal on OpenCart on any page?</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload