Saturday, 19 August 2017

Add manually limit number of post in WordPress

Here the code for Add  manually limit number of post in WordPress:

$args = array(
'post_type' => 'post',
'posts_per_page' => 12,
'paged' => $page,
);

query_posts($args);

Return MySQL data in JSON format

Here is the code for Return MySQL data in JSON format:

$con=mysqli_connect($servername,$username,$password,$databasename);
if (mysqli_connect_errno())
{
echo "Connection Error" . mysqli_connect_error();
}
$query = "SELECT * FROM TableName";
$result = mysqli_query($con,$query);
$querydata = array();
while($data = mysqli_fetch_array($result)) {
$querydata[] = $data;
}
echo json_encode($querydata);
mysqli_close($con);

Convert Codeigniter data to json

Here is the code for Convert Codeigniter data to json:

public function lastActivity()
{
    header("Content-Type: application/json");
    $this->db->select('*');
    $this->db->from('table_name');
    $query = $this->db->get();

    return json_encode($query->result());
}

Select all anchors with a specific href with jquery

Here is the code for Select all anchors with a specific href with jquery:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
      <script>
      $(document).ready(function(){
        $("a").each(function(){
    if($(this).attr("href") == "http://example.com/external/link/")
    {
        $(this).hide();
    }
});
});
 </script>
  <a href="http://example.com/external/link/">a website link</a>

Add three dots at end of line with css

Add three dots at end of line with css here is the code:

.add-three-dots{display: inline-block;

   width: 240px;
   white-space: nowrap;
   overflow: hidden;
   text-overflow: ellipsis;
   background: #FFFCD7;
    padding: 5px;
     }
 <span class="add-three-dots">How To Add Three Dots In the End Of String with Css And Jquery?</span>

Google Map Filter Api Example

Here is Google Map Filter Api Example: