my code stock.com

Juan Carlos Nava

ACTUAL NEWS FRONT 2018 (LOOP)
by Juan Carlos Nava

Snippet options

Download: Download snippet as actual-news-front-2018-loop.html.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

function actualnews_front_function( $atts ){ 

  $idioma = pll_current_language();
  $nick="puertassanti";
  $website = "https://puertassanti.actualsi.com/";
  $contanots = 0;

  if($idioma=='ca'){

	$lenguaje="cat";
	$vermas="Lleguir més";
	$slugan ="noticia-cat";

  }
  elseif ($idioma=='fr') 
  {

	$lenguaje="";
	$vermas="";
	$slugan ="";	

  }
  elseif($idioma=='en')
  {
	
	$lenguaje="eng";
	$vermas="View more";
	$slugan ="news";	

  }
  else {

	$lenguaje="esp";
	$vermas="Leer más";
	$slugan ="noticia";	

  }  
  ?>
	
	
	
	
	
 
				<!-- ACA VA EL HTML DEL TOP -->
	
	
	
	
	

  <?php 		
			
  $url='https://www.actualnews.es/zona_clients/rss_complet.php?nick='.$nick.'&lang='.$lenguaje.'&contingut=llarg&l=3';
  $xml = simplexml_load_file($url);
  $xml2 = json_decode(json_encode($xml->noticies) , true); 

  // SOLO PARA DEBUG
  //echo "<pre>"; print_r($xml);echo "</pre>";
  //echo "<pre>"; print_r($idioma);echo "</pre>";
  //echo "<pre>"; print_r($url); echo "</pre>";
  //echo "<pre>"; echo count($xml2['noticia']); echo "</pre>";
  //echo "<pre style='font-size:8px;''>"; print_r($noticia); echo "</pre>";
  
  ////////////////////

  foreach ($xml->noticies as $noticia) {

	foreach ($noticia as $key => $value) {

		//echo $value->idNoticia; echo "<br>";
		$id = $value->idNoticia;
		$title = $value->title;
		if (strlen($title)>60){
		  $titol = trim(substr($title, 0, 50))." ... ";
		}				  
		$url=$website.$slugan."/".$id."/".sanitize_title($title);
		$description = $value->description;
		$description_sintag = strip_tags($description);
		$desc_curt = trim(substr($description_sintag, 0, 120))."...";
		$data = strftime("%d-%b-%Y", strtotime($value->data));
		$imatge_principal = $value->imatge_principal;
		$partes = explode("-", $value->data);
		$ano = $partes[0];
		$mes = $partes[1];
		$dia = $partes[2];

		?>

		
		<p><?php echo $imatge_principal; ?></p>
		<p><?php echo $vermas; ?></p>
		<p><?php echo $data; ?></p>
		<p><?php echo $desc_curt; ?></p>
		<p><?php echo $titol; ?></p>
		<hr />
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		
		
		<!-- ACA VA EL HTML QUE SE REPITE, EL RECURSIVO -->
		  
		  
		  
		  
		
		


  



  
  


    <?php $contanots++; } } ?>
	
	
	
	



  				<!-- ACA VA EL HTML DEL BOTTOM -->
	
	
	
	
	


<?php } add_shortcode( 'actualnews_front', 'actualnews_front_function' );


Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.