impossible Posted June 8, 2015 Share Posted June 8, 2015 hello i use wordpress for front page my site and use whmcs for client area. i need code for show knowledgebase popular post on my front page of wordpress please help me 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted June 8, 2015 Share Posted June 8, 2015 how to count one article as popular by views or useful votes? i'm not sure how you can integrate it with WordPress but to get the top articles we can query our database by create new file in client area let's name it kbapi.php or something else and add the following code inside it: <?php define("CLIENTAREA",true); require("init.php"); header("Content-Type: application/json; charset=utf-8"); $output = array(); # Get Articles based on views $select_articles = full_query("SELECT * FROM `tblknowledgebase` WHERE `private`!='on' AND `parentid`='0' ORDER BY `views` DESC LIMIT 5"); while ($article = mysql_fetch_assoc($select_articles)){ $output[] = array( "id" => $article['id'], "title" => stripslashes($article['title']), "article" => html_entity_decode(stripslashes($article['article'])), "views" => $article['views'], "url" => $CONFIG['SystemURL'] . '/knowledgebase.php?action=displayarticle&id='.$article['id'] ); } echo json_encode($output); ?> this will give you the top five articles based on views, also the output is set to JSON format this way you can integrate it easily using Javascript if you which 0 Quote Link to comment Share on other sites More sharing options...
impossible Posted June 9, 2015 Author Share Posted June 9, 2015 how to count one article as popular by views or useful votes? i'm not sure how you can integrate it with WordPress but to get the top articles we can query our database by create new file in client area let's name it kbapi.php or something else and add the following code inside it: <?php define("CLIENTAREA",true); require("init.php"); header("Content-Type: application/json; charset=utf-8"); $output = array(); # Get Articles based on views $select_articles = full_query("SELECT * FROM `tblknowledgebase` WHERE `private`!='on' AND `parentid`='0' ORDER BY `views` DESC LIMIT 5"); while ($article = mysql_fetch_assoc($select_articles)){ $output[] = array( "id" => $article['id'], "title" => stripslashes($article['title']), "article" => html_entity_decode(stripslashes($article['article'])), "views" => $article['views'], "url" => $CONFIG['SystemURL'] . '/knowledgebase.php?action=displayarticle&id='.$article['id'] ); } echo json_encode($output); ?> this will give you the top five articles based on views, also the output is set to JSON format this way you can integrate it easily using Javascript if you which thanks you , create kb.ph and copy code into file , but cant opened file and get error. 0 Quote Link to comment Share on other sites More sharing options...
impossible Posted June 9, 2015 Author Share Posted June 9, 2015 thanks you , create kb.ph and copy code into file , but cant opened file and get error. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted June 9, 2015 Share Posted June 9, 2015 kb.ph ?? what the error message is? 0 Quote Link to comment Share on other sites More sharing options...
impossible Posted June 9, 2015 Author Share Posted June 9, 2015 sorry , kbapi.php . get bellow error : Tahoma,sans-serif; color: #333333;\" lang=\"FA\">\u062a\u0627 \u0627\u0632 \u062a\u0645\u0627\u0645\u06cc \u0627\u0645\u06a9\u0627\u0646\u0627\u062a \u0627\u0648\u0646 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f\u00a0<\/span><span style=\"font-family: Tahoma,sans-serif; color: #333333;\">.<\/span><\/span> <\/span><\/div>","views":"533","url":"http:\/\/my.mysitename.com\/knowledgebase.php?action=displayarticle&id=4"}] 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted June 9, 2015 Share Posted June 9, 2015 it's JSON no errors, i made it this way so it will be easy for you to parse it using PHP or Javascript, as you currently use Wordpress it will be easy to you to edit your theme files header/footer add cURL function that parse this data into WordPress or use AJAX if you which to use Javascript instead 0 Quote Link to comment Share on other sites More sharing options...
impossible Posted June 9, 2015 Author Share Posted June 9, 2015 i need example code , this code read rss post , <ul> <?php include_once(ABSPATH . WPINC . '/rss.php'); $rss = fetch_rss('http://www.mysitename.com/feed'); $maxitems = 10; $items = array_slice($rss->items, 0, $maxitems); ?> <ul> <?php if (empty($items)) echo '<li>no post</li>'; else foreach ( $items as $item ) : ?> <li><a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'> <?php echo $item['title']; ?> </a></li> <?php endforeach; ?> </ul> 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted June 9, 2015 Share Posted June 9, 2015 check this one http://forum.whmcs.com/showthread.php?41207-Knowledgebase-RSS-feed i didn't saw it before now 0 Quote Link to comment Share on other sites More sharing options...
impossible Posted June 9, 2015 Author Share Posted June 9, 2015 thank you , but this code show all knowlegbase post , i need popular posts. 0 Quote Link to comment Share on other sites More sharing options...
impossible Posted June 11, 2015 Author Share Posted June 11, 2015 i need code for rss show popular posts. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 11, 2015 Share Posted June 11, 2015 from the RSS link that sentq gave, have you tried replacing the SQL query... $result = mysql_query("SELECT * FROM tblknowledgebase"); which is showing all articles, with the SQL query specified by sentq in his above post? $result = full_query("SELECT * FROM `tblknowledgebase` WHERE `private`!='on' AND `parentid`='0' ORDER BY `views` DESC LIMIT 5"); 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.