This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
PHP decode starting with $OOO000000=urldecode('%66%67%36%73%62%65%68%70%72%61%34%63
This wordpress theme can get a big 10 on evil scale. The functions.php file is fully encoded so as you can't get rid of the footer link. But it also prevent us to improve the theme and that's a shame.
So, anyone can decode this ? I tried with online decoders, can't get it right.
Thanks a lot !
<?php /* */$OOO000000=urldecode('%66%67%36%73%62%65%68%70%72%61%34%63%6f%5f%74%6e%64');$OOO0000O0=$OOO000000{4}.$OOO000000{9}.$OOO000000{3}.$OOO000000{5};$OOO0000O0.=$OOO000000{2}.$OOO000000{10}.$OOO000000{13}.$OOO000000{16};$OOO0000O0.=$OOO0000O0{3}.$OOO000000{11}.$OOO000000{12}.$OOO0000O0{7}.$OOO000000{5};$OOO000O00=$OOO000000{0}.$OOO000000{12}.$OOO000000{7}.$OOO000000{5}.$OOO000000{15};$O0O000O00=$OOO000000{0}.$OOO000000{1}.$OOO000000{5}.$OOO000000{14};$O0O000O0O=$O0O000O00.$OOO000000{11};$O0O000O00=$O0O000O00.$OOO000000{3};$O0O00OO00=$OOO000000{0}.$OOO000000{8}.$OOO000000{5}.$OOO000000{9}.$OOO000000{16};$OOO00000O=$OOO000000{3}.$OOO000000{14}.$OOO000000{8}.$OOO000000{14}.$OOO000000{8};$OOO0O0O00=__FILE__;$OO00O0000=0x908;eval($OOO0000O0('JE8wMDBPME8wMD0kT09PMDAwTzAwKCRPT08wTzBPMDAsJ3JiJyk7JE8wTzAwT08wMCgkTzAwME8wTzAwLDB4NDgxKTskT08wME8wME8wPSRPT08wMDAwTzAoJE9PTzAwMDAwTygkTzBPMDBPTzAwKCRPMDAwTzBPMDAsMHgxN2MpLCdzME1PZzRjbGRIMXVtRUtxL1lRb3hiQlpTOHlGMkphUmpQTDUzcjlBeitlQzdVR3ZocElUbjZ0TmZWaVhEd2tXPScsJ0FCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eX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rBIYGJB6JuM2LHIh3StprSBVc1Qn3StprSBVcKhz3yB6AbcP6FBdjqQ0TJBHTJldzHcrUSBJrBIYGJB6JuMY5FcbPF3S7HcE78B4G/L3XMAn1yBSz2NYIyZEn2Lj3yB6P8tbFHcV6Fbn7HTp+FB2A1Q3jatb5ycDjHcrU86YzJB6LKNn1Hc6v29xjqQshKh+wM986F9EnyBwGdcEPJlERFBbvJIj38tp68Q3jahz3SNbI29bGJ4w5SZ/jqQ0TyBVAFcbRSt4nZNY+Jcpr1MsAHIp9SBpT8Qs+Khz32tbhSZHPJcwIdOnjdrpGd571HcEPJlmjqQ0ral07FtYr1Ms32tbhSZHPJcwIucJrJ4wnycbRSt4n8BJv2ArRFcrTJMj32tbhSZHPJcwI1Qs+Kh+9FNHrSBEzdMjjHcEPJlmjSZmjHc3jqof32NYIdM3jah++8LszdlEn2AEn2LjjHlEn2LhLqLY5JZHI8BVnZtEPJOhL1Qs+dl71JBVT8Z/zHcEPJlEFHcrJ1o71SAHrSB7XMAn1R/++8LszdcbU2lYV1MY5SZYT1Qs+MAHrJlbIFL09SBpT8o7129bnJZHGdlYIyBnzy9w+FLjjHcJ7JBx7HcEPJlmj1Q3XMAn1BWhylSK
Examine this line:
$OOO000000 = urldecode('%66%67%36%73%62%65%68%70%72%61%34%63%6f%5f%74%6e%64');
Decode that here
$OOO000000 = 'fg6sbehpra4co_tnd';
Then take the next line:
$OOO0000O0 = $OOO000000{4}.$OOO000000{9}.$OOO000000{3}.$OOO000000{5};
Which basically says take character 4, 9, 3, 5 from that string (index starting from 0), so we get...
$OOO0000O0 = 'base';
Now try the rest yourself.
Start by make the code a little more readable:
<?php
$OOO000000=urldecode('%66%67%36%73%62%65%68%70%72%61%34%63%6f%5f%74%6e%64');
$OOO0000O0=$OOO000000{4}.$OOO000000{9}.$OOO000000{3}.$OOO000000{5};
$OOO0000O0.=$OOO000000{2}.$OOO000000{10}.$OOO000000{13}.$OOO000000{16};
$OOO0000O0.=$OOO0000O0{3}.$OOO000000{11}.$OOO000000{12}.$OOO0000O0{7}.$OOO000000{5};
$OOO000O00=$OOO000000{0}.$OOO000000{12}.$OOO000000{7}.$OOO000000{5}.$OOO000000{15};
$O0O000O00=$OOO000000{0}.$OOO000000{1}.$OOO000000{5}.$OOO000000{14};
$O0O000O0O=$O0O000O00.$OOO000000{11};
$O0O000O00=$O0O000O00.$OOO000000{3};
$O0O00OO00=$OOO000000{0}.$OOO000000{8}.$OOO000000{5}.$OOO000000{9}.$OOO000000{16};
$OOO00000O=$OOO000000{3}.$OOO000000{14}.$OOO000000{8}.$OOO000000{14}.$OOO000000{8};
$OOO0O0O00=__FILE__;
$OO00O0000=0x908;
eval($OOO0000O0('JE8wMDBPME8wMD0kT09PMDAwTzAwKCRPT08wTzBPMDAsJ3JiJyk7JE8wTzAwT08wMCgkTzAwME8wTzAwLDB4NDgxKTskT08wME8wME8wPSRPT08wMDAwTzAoJE9PTzAwMDAwTygkTzBPMDBPTzAwKCRPMDAwTzBPMDAsMHgxN2MpLCdzME1PZzRjbGRIMXVtRUtxL1lRb3hiQlpTOHlGMkphUmpQTDUzcjlBeitlQzdVR3ZocElUbjZ0TmZWaVhEd2tXPScsJ0FCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5Ky8nKSk7ZXZhbCgkT08wME8wME8wKTs='));
return;
?>
f]pDOJwHgwqmO0qmO0qmO6TJlHR29bhFc458QjAZ6wcQxp4Z6DAuMdAdLf3onwqmgDhoTshuLdAdLh3onwqmOshmgDh1MYqonDhmOshmgDzHgDhoTshonDhmMj3oTshmgDhoTshuMYqoTshoTshmOs+uMJTmg6q8TY5FcYdmZbUYxUpu6rYFNPL/r+oKlrcm3+Px9+/oOxT25r0aLUr/TJbYN8z2grxF58no98BybPgJtUZqQ27Hn4M/nY4Y3JdQx+uog6Ko60YxrExbb8ZB4rySBH58cb98tP+y9U7FBVv2l4I2NY6JAJfa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cwIucJrJ4wnycbRSt4n8BJv2ArRFcrTJMj32tbhSZHPJcwI1Qs+Kh+9FNHrSBEzdMjjHcEPJlmjSZmjHc3jqof32NYIdM3jah++8LszdlEn2AEn2LjjHlEn2LhLqLY5JZHI8BVnZtEPJOhL1Qs+dl71JBVT8Z/zHcEPJlEFHcrJ1o71SAHrSB7XMAn1R/++8LszdcbU2lYV1MY5SZYT1Qs+MAHrJlbIFL09SBpT8o7129bnJZHGdlYIyBnzy9w+FLjjHcJ7JBx7HcEPJlmj1Q3XMAn1BWhylSK
Then change eval to echo eval. I think that should at least get you started.
<?php
if (function_exists('register_sidebar'))
register_sidebar(array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '',
'after_title' => '<br />',
));
function widget_yes_search() {
;
echo '
';
_e('Search');
;
echo ' <form id="searchform" method="get" action="';
echo $_SERVER['PHP_SELF'];
;
echo '">
<div>
<input type="text" name="s" id="s" size="15" /><br />
';
;
echo ' </div>
</form>
';
}
if (function_exists('register_sidebar_widget'))
register_sidebar_widget(__('Search'), 'widget_yes_search');
function GET_F0OTER() {
;
echo '
<div id="credit">
© ';
echo date('Y');
;
echo ' ';
bloginfo('name');
;
echo '. All right reserved.<br />
Designed by Duncan Cox
</div>
</div>
</body>
</html>
';
}
function getImage($num) {
global $more;
$more = 1;
$content = get_the_content();
$count = substr_count($content, '<img');
$start = 0;
for ($i = 1; $i <= $count; $i++) {
$imgBeg = strpos($content, '<img', $start);
$post = substr($content, $imgBeg);
$imgEnd = strpos($post, '>');
$postOutput = substr($post, 0, $imgEnd + 1);
$image[$i] = $postOutput;
$start = $imgEnd + 1;
$cleanF = strpos($image[$num], 'src="') + 5;
$cleanB = strpos($image[$num], '"', $cleanF) - $cleanF;
$imgThumb = substr($image[$num], $cleanF, $cleanB);
}
if (stristr($image[$num], '<img')) {
echo $imgThumb;
}
$more = 0;
}
function cats_meow($glue) {
$current_cat = single_cat_title('', false);
$separator = "\n";
$cats = explode($separator, get_the_category_list($separator));
foreach ($cats as $i => $str) {
if (strstr($str, ">$current_cat<")) {
unset($cats[$i]);
break;
}
}
if (empty($cats))
return false;
return trim(join($glue, $cats));
}
Related
This is my code to give alt attribute to all images on published post.
It works fine for all images on normal post.
function auto_alt_set($html)
{
global $post;
$pic_alt = get_the_title();
if ($pic_alt !== '') {
$html = str_replace('alt=""', 'alt="' . esc_attr($pic_alt) . '"', $html);
}
return $html;
}
add_filter('the_content', 'auto_alt_set');
Now I like to know how I can set alt attribute to images that are extracted from content by the following code.
<?php
$beforeEachImage = "<div>";
$afterEachImage = "</div>";
preg_match_all("/(<img [^>]*>)/", get_the_content(), $matches, PREG_PATTERN_ORDER);
for ($i = 0; isset($matches[1]) && $i < count($matches[1]); $i++) {
echo $beforeEachImage . $matches[1][$i] . $afterEachImage;
}
?>
I developed a small one-file plugin for a wordpress site. It's just adds an upload form for a file that POSTs to itself and then does some stuff with the file's contents once submitted.
It works fine on the staging environment, but on the live server there is a strange problem. Once I submit the form with the file the server does not bring me back to the same page but instead returns the following JSON:
{"success":false,"message":"Please enter a message."}
I am at loss what could be causing this. Has anybody come across such a problem?
The (simplified plugin):
function show_upload_form() {
if ($_FILES['userfile']) {
echo "<p>file received</p>";
$file = fopen($_FILES['userfile']['tmp_name'], "r");
$data = [];
while (!feof($file)) {
$data[] = fgetcsv($file,null,';');
}
foreach ($data as $line) {
$pid = $line[0];
if (isset($line[1])) {
$price = trim(str_replace(',', '.', $line[1]));
} else {
$price = "";
}
if (isset($line[2])) {
$title = trim(iconv("ISO-8859-1", "UTF-8", $line[2]));
} else {
$title = "";
}
global $wpdb;
$product_ids = $wpdb->get_results($wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s'", $pid));
foreach ($product_ids as $product_id) {
$elem = $product_id->post_id;
if ($price != "") {
update_post_meta($elem, '_price', $price);
update_post_meta($elem, '_sale_price', $price);
update_post_meta($elem, '_regular_price', $price);
}
if ($title != "") {
wp_update_post(array(
'ID' => $elem,
'post_title' => $title,
));
}
}
echo "<p>Produkt #".$pid;
if ($price != "") {
echo " - new price: ".$price."€";
}
if ($title != "") {
echo "- new title: ".$title;
}
}
} else {
echo "<form method=\"post\" enctype=\"multipart/form-data\">";
echo "<label for=\"file\">Select a file:</label>";
echo "<input type=\"file\" name=\"userfile\" id=\"file\">";
echo "<br /><br />";
echo "<button>Upload File</button>";
echo "<form>";
}
}
I appreciate any input.
Try something like this
<form action="<?=admin_url( 'admin-post.php' ) ?>" method="POST">
<input type="hidden" name="action" value="my_custom_plugin_action"/>
<input type="submit" value="SEND"/>
</form>
add_action( 'admin_post_nopriv_my_custom_plugin_action',array( "class_that_owns_that_function", 'show_upload_form' ) );
public function show_upload_form()
{
//Here write your code
}
Problem disappeared after deactivating and individually reactivating all the plugins for the second or third time. Guess this one will remain a mystery ...
I'm new to php and wordpress.
When I edit an icon box from the theme in the admin panel, i have a few fields, like "title" and "content". The title is inside <h4> </h4> and content is inside <p>
</p>
I need to add another <p style='iconbox_price'></p> after the content, so i can edit it in the admin panel.
This is the code for the iconbox. How can i add this to it, so it would work out.
<?php
function easyweb_webnus_iconbox( $attributes, $content = null ) {
extract(shortcode_atts(array(
"type"=>'',
'icon_title'=>'',
'icon_link_url'=>'',
'icon_link_text'=>'',
"icon_name"=>'',
"iconbox_content"=>'',
"icon_size"=>'',
"icon_color"=>'',
"title_color"=>'',
"content_color"=>'',
"link_color"=>'',
"icon_image"=>'',
"featured"=>'',
"border_left"=>'',
"border_right"=>'',
), $attributes));
ob_start();
$type = ( $type == 0 ) ? '' : $type ;
$iconbox_style = $type17_start_wrap = $type17_end_wrap = '';
if ( $type==17 ) {
$iconbox_style = ( !empty($icon_color) ) ? ' style="color: ' . esc_attr($icon_color) . '"' : '' ;
$type17_start_wrap = '<div class="icon-wrap" style="background-color:' . esc_attr($icon_color) . '">';
$type17_end_wrap = '</div>';
}
$iconbox22_class = '';
if ( $type == 22 ) {
$iconbox22_class .= $featured ? ' ' . $featured : '';
$iconbox22_class .= $border_left ? ' ' . $border_left : '';
$iconbox22_class .= $border_right ? ' ' . $border_right : '';
}
echo '<article class="icon-box' . $type . $iconbox22_class . '" ' . $iconbox_style . '>';
if(!empty($icon_name) && $icon_name != 'none') :
if(!empty($icon_link_url))
echo '' . $type17_start_wrap . '' . do_shortcode( "[icon name='$icon_name' size='$icon_size' color='$icon_color']" ).'' . $type17_end_wrap . '';
else
echo $type17_start_wrap . do_shortcode( "[icon name='$icon_name' size='$icon_size' color='$icon_color']" ) . $type17_end_wrap;
elseif(!empty($icon_image)) :
if(is_numeric($icon_image)){
$icon_image = wp_get_attachment_url( $icon_image );
}
if(!empty($icon_link_url))
echo "<a href='$icon_link_url'>" . '<img src="'.$icon_image.'" alt="" />' . '</a>' ;
else
echo '<img src="'.$icon_image.'" alt="" />';
endif;
$title_style = !empty($title_color)?' style="color:'.$title_color.'"':'';
echo '<h4'.$title_style.'>' . $icon_title . '</h4>';
$content_style = !empty($content_color)?' style="color:'.$content_color.'"':'';
echo '<p'.$content_style.'>'.$iconbox_content .'</p>' ;
$link_style = !empty($link_color)?' style="color:'.$link_color.'"':'';
echo (!empty($icon_link_url) && (!empty($icon_link_text)) )?"<a".$link_style." class=\"magicmore\" href=\"{$icon_link_url}\">{$icon_link_text}</a>":'';
echo '</article>';
$out = ob_get_contents();
ob_end_clean();
$out = str_replace('<p></p>','',$out);
return $out;
}
add_shortcode('iconbox', 'easyweb_webnus_iconbox');
In html this is the code, that is generated:
<article class="icon-box14">
<a href="/razrabotka-saitov/">
<i class="sl-screen-desktop" style=" font-size:42px;"></i>
</a>
<h4 style="height: 22px;">Title</h4>
<p style="height: 116px;">Content<br></p>
<a class="magicmore" href="#">More</a>
</article>
You see the line there:
echo '<p'.$content_style.'>'.$iconbox_content .'</p>' ;
You can add your custom paragraph to that line:
echo '<p'.$content_style.'>'.$iconbox_content .'</p>
<p style='iconbox_price'></p>' ;
I found the solution in my case. Maybe it will help somebody else. I had to edit two files. In my case this is where the first file was located.
wp-content/plugins/'theme'-shortcodes/shortcodes/iconbox.php
I tried to look for where comes the variable $iconbox_content and found it in getting extracted in the code above from an array at this point:
extract(shortcode_atts(array(
"type"=>'',
'icon_title'=>'',
'icon_link_url'=>'',
'icon_link_text'=>'',
"icon_name"=>'',
"iconbox_content"=>'',
"icon_size"=>'',
"icon_color"=>'',
"title_color"=>'',
"content_color"=>'',
"link_color"=>'',
"icon_image"=>'',
"featured"=>'',
"border_left"=>'',
"border_right"=>'',
), $attributes));
So i searched through all the wordpress directory files, because i did not even have an idea where can i find it.
And found it in the themes => 'my theme' => 'my theme' => visualcomposer => shortcodes directory as 03-iconbox.php
I had there different arrays such as this:
array(
"type"=>'textarea',
"heading"=>esc_html__('Content', 'ew'),
"param_name"=> "iconbox_content",
"value"=>"",
"description" => esc_html__( "IconBox Content Goes Here", 'ew')
),
So i guess, the other half of what i did is very logical already, but here it is anyway:
I added an array in this file:
array(
"type"=>'textarea',
"heading"=>esc_html__('Price', 'ew'),
"param_name"=> "iconbox_price",
"value"=>"",
"description" => esc_html__( "Price goes here", 'ew')
),
And in the first file:
To extract "iconbox_price" =>'',
And lower: echo '<p class="iconbox_price">'.$iconbox_price .'</p>' ;
Wish that this helps someone!
I'm working with a custom function for page navigation in Wordpress, based on the one used in the Bones theme (http://themble.com/bones). The function outputs numbered page links, but also outputs both previous and next page buttons, even when you are on the first or last page. I want to adapt it to only show the previous page button when you are not on the first page, and only show the next page button when you are not on the last page. Hopefully that makes sense!
Here's the function:
function custom_page_navi($before = '', $after = '') {
global $wpdb, $wp_query;
$request = $wp_query->request;
$posts_per_page = intval(get_query_var('posts_per_page'));
$paged = intval(get_query_var('paged'));
$numposts = $wp_query->found_posts;
$max_page = $wp_query->max_num_pages;
if ( $numposts <= $posts_per_page ) { return; }
if(empty($paged) || $paged == 0) {
$paged = 1;
}
$pages_to_show = 7;
$pages_to_show_minus_1 = $pages_to_show-1;
$half_page_start = floor($pages_to_show_minus_1/2);
$half_page_end = ceil($pages_to_show_minus_1/2);
$start_page = $paged - $half_page_start;
if($start_page <= 0) {
$start_page = 1;
}
$end_page = $paged + $half_page_end;
if(($end_page - $start_page) != $pages_to_show_minus_1) {
$end_page = $start_page + $pages_to_show_minus_1;
}
if($end_page > $max_page) {
$start_page = $max_page - $pages_to_show_minus_1;
$end_page = $max_page;
}
if($start_page <= 0) {
$start_page = 1;
}
echo $before.'<nav class="pagination"><ol class="custom_page_navi">'."";
if ($start_page >= 2 && $pages_to_show < $max_page) {
$first_page_text = __( "First");
echo '<li class="cpn-first-page-link">'.$first_page_text.'</li>';
}
echo '<li class="cpn-prev-link">';
previous_posts_link('');
echo '</li>';
for($i = $start_page; $i <= $end_page; $i++) {
if($i == $paged) {
echo '<li class="cpn-current">'.$i.'</li>';
} else {
echo '<li>'.$i.'</li>';
}
}
echo '<li class="cpn-next-link">';
next_posts_link('');
echo '</li>';
if ($end_page < $max_page) {
$last_page_text = __( "Last");
echo '<li class="cpn-last-page-link">'.$last_page_text.'</li>';
}
echo '</ol></nav>'.$after."";
}
Any ideas?
Why not just leave it? Also Bones official Git can be helpful, open a support issue there with this question. Anyways try this untested code :
Change this:
if ($end_page < $max_page) {
$last_page_text = __( "Last", 'bonestheme' );
echo '<li class="bpn-last-page-link">'.$last_page_text.'</li>';
}
To this:
if ($end_page < $max_page && != $max_page) {
$last_page_text = __( "Last", 'bonestheme' );
echo '<li class="bpn-last-page-link">'.$last_page_text.'</li>';
}
Hello i have a website and a blog, i want to display my self hosted wordpress blog on my website.
I want to show only 3 post on my website.
I want to automatically check for any new post everytime when i reload my website, so that the recent three gets displayed only.
I want to show the complete title of my wordpress blogpost but specific letters of description.
Also the description should end up with a word not some piece of non-dictionary word ending with "..."
How this can be done, i have heard that it can be done through RSS.
Can somebody help me?
To accomplish this you need to read the RSS of the blog, from RSS you need to read the Title and the description, after reading the whole description and title you need to trim the description to your desired number of letters. After that you need to check weather the description last word has been completed or not and then you need to remove a the last word if not completed and put the "...".
First we will make a script to trim the description and to put "..." in last:-
<?php
global $text, $maxchar, $end;
function substrwords($text, $maxchar, $end='...') {
if (strlen($text) > $maxchar || $text == '') {
$words = preg_split('/\s/', $text);
$output = '';
$i = 0;
while (1) {
$length = strlen($output)+strlen($words[$i]);
if ($length > $maxchar) {
break;
}
else {
$output .= " " . $words[$i];
++$i;
}
}
$output .= $end;
}
else {
$output = $text;
}
return $output;
}
Now we will define the variables in which we store the values:-
$xml=("http://your-blog-path/rss/");
global $item_title, $item_link, $item_description;
$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);
$x=$xmlDoc->getElementsByTagName('item');
Now, we will make an array and store values in it. I am only taking 3 because you have asked it the way. You can change it to anything (The number of post you want to show, put that in the loop)
for ($i=0; $i<3; $i++)
{
$item_title[$i] = $x->item($i)->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;
$item_link[$i] = $x->item($i)->getElementsByTagName('link')->item(0)->childNodes->item(0)->nodeValue;
$item_description[$i] = $x->item($i)->getElementsByTagName('description')->item(0)->childNodes->item(0)->nodeValue;
}
?>
Now echo all these values, Link is the value where your user will click and he will be taken to your blog:-
FIRST RECENT POST:
<?php echo $item_title[0]; ?>
<?php echo substrwords($item_description[0],70); ?>
SECOND RECENT POST:
<?php echo $item_title[1]; ?>
<?php echo substrwords($item_description[1],70); ?>
THIRD RECENT POST:
<?php echo $item_title[2]; ?>
<?php echo substrwords($item_description[2],70); ?>
Hope this can solve your problem. By the way Nice question.
Click here for the original documentation on displaying RSS feeds with PHP.
Django Anonymous's substrwords function is being used to trim the description and to insert the ... at the end of the description if the it passes the $maxchar value.
Full Code:
blog.php
<?php
global $text, $maxchar, $end;
function substrwords($text, $maxchar, $end='...') {
if (strlen($text) > $maxchar || $text == '') {
$words = preg_split('/\s/', $text);
$output = '';
$i = 0;
while (1) {
$length = strlen($output)+strlen($words[$i]);
if ($length > $maxchar) {
break;
} else {
$output .= " " . $words[$i];
++$i;
}
}
$output .= $end;
} else {
$output = $text;
}
return $output;
}
$rss = new DOMDocument();
$rss->load('http://wordpress.org/news/feed/'); // <-- Change feed to your site
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
);
array_push($feed, $item);
}
$limit = 3; // <-- Change the number of posts shown
for ($x=0; $x<$limit; $x++) {
$title = str_replace(' & ', ' & ', $feed[$x]['title']);
$link = $feed[$x]['link'];
$description = $feed[$x]['desc'];
$description = substrwords($description, 100);
$date = date('l F d, Y', strtotime($feed[$x]['date']));
echo '<p><strong>'.$title.'</strong><br />';
echo '<small><em>Posted on '.$date.'</em></small></p>';
echo '<p>'.$description.'</p>';
}
?>
You can easily put this in a separate PHP file (blog.php) and call it inside your actual page.
Example:
social.php
<h3>Latest blog post:</h3>
<?php require 'blog.php' ?>
Also, this code is plug-n-play friendly.
Why not use the Wordpress REST API to retrieve posts -
API URL is : https://public-api.wordpress.com/rest/v1/sites/$site/posts/
where $site is the site id of your wordpress blog
or else simply use this plugin -
http://www.codehandling.com/2013/07/wordpress-feeds-on-your-website-with.html