To create Widget: €œLast Entrances Blog€, for an external Web to WP

If you have a blog in WordPress podeis to easily create a section in the zone of Widgets that makes reference to the €œlast written entrances€, but and if you want to manually create that Widget in an external Web totally other people's to this WordPress? , how it would be made?

wordpress

STEPS TO REALISE A €œWIDGET WORDPRESS€ IN AN EXTERNAL WEB TO WORDPRESS

  • to 1.Crear a field €œdescription of the entrance€ in the data base WordPress
    I personally take advantage of the field metadescripci³n that the Plugin SEO de Yoast offers to me, but any other plugin of SEO will realise the same function to us.
    Therefore we installed the Plugin Yoast in our WordPress, and filled up the description fields.
  • 2. To observe the new field created in Base de Datos
    Now we opened the data base WordPress and observed that:
    you-wp

    Within €œthe wp_postmeta€ table the field has been created €œmeta_value€, that corresponds to the description of the entrance which we have written previously.
    In addition the field post_id is autoincremental, and the last entrances have a higher value.

  • 3. Dar Acceso to the data base for external requests
    In this servant where the data base WordPress lodges, it will be important to give to access to external requests mysql, for it we will look for the file normally my.conf that this available one in /etc/my.cnf, (if the servant is linux), next we will modify the line that puts €œbind-address= 127.0.0.1€ and we will replace it by €œbind-address = 0.0.0.0 €œ, later will be necessary to do restart of mysql €œservice mysql restart€.
    With this what we are doing he is to say to daemon mysqld to him that he listens to external requests.
    my-conf
    my-conf
  • 4. Code PHP for the external Web to WordPress
    Finally we realised code PHP in charge to be in screen the description of the last entrances written in our Blog.
    In the website other people's to the WordPress of our Blog we created this code:
    <? php                
    $conwp=mysqli_connect (€œ90.121.178.56€, €œuser_bd€, €œpassword_bd€, €œnombre_bd€);
    //conexi ³n to the data base wordpress to header (€œContent-Type: text/HTML; charset=utf-8€);
    $acentos = $conwp->query (€œSET YAMS €˜utf8€™€);
    //Para to show to the accents //Check connection if (mysqli_connect_errno ())
      \ {
      I throw €œFailed to connect to MySQL: €. mysqli_connect_error ();
      } //aqu i we created the consultation to the data base WordPress, in this case we selected 3 last the $resultado ones = mysqli_query ($conwp, €œselect meta_value from wp_postmeta where meta_value LIKE €˜%a%€™ and meta_key='_yoast_wpseo_metadesc' to order by post_id desc limit 0, 3€);
    
    //creamos a listing with the descriptions of the entrances I throw €œ<ul style='color: congregation; margin-left: 8px; padding: 0px; €˜>€;  
    
    while ($row = mysqli_fetch_array ($resultado))
    \ {I throw €œ<a href='http://www.dominio.com/blog'><li style='color: congregation; margin-left: 10px; margin-top: 11px; text-align: justify; margin-right: 10px; €˜>€. $row [€˜meta_value€™]. €œ</li></a>€;} I throw €œ</ul>€;   
    mysqli_close ($conwp);   
    >

Now we observed the result when sailing by this Web and to execute code PHP, already we have our own €œwidget€ ready to use.

I hope that this article serves to you as help,
A greeting,
Oscar/Devservice.es

By “scar Carrillo