Saturday, 27 August 2016

Change the height of the Revolution Slider in wordpress

Please add this code in Customize -> Custom -> CSS:

.rev_slider_wrapper, .rev_slider, .tp-fullwidth-forcer, .rev_slider .tp-bgimg.defaultimg {
    max-height: 400px !important;

}

Hope it helps.

Monday, 22 August 2016

Wednesday, 17 August 2016

Get post data by id using AJAX in wordpress

Add below code on your theme's function.php

add_action('wp_ajax_nopriv_ajax_request', 'ajax_handle_request');
add_action('wp_ajax_ajax_request', 'ajax_handle_request');

function ajax_handle_request(){

    $postID = $_POST['id'];
    if (isset($_POST['id'])){
        $post_id = $_POST['id'];
    }else{
        $post_id = "";
    }

    global $post;
    $post = get_post($postID);

    $response = array( 
        'sucess' => true, 
        'post' => $post,
        'id' => $postID , 
    );

    // generate the response
    print json_encode($response);

    // IMPORTANT: don't forget to "exit"
    exit;
}
Using jQuery to retrieve the data and output.
jQuery(document).ready(function($) {

  $('.ajax a').click(function(event) {
    event.preventDefault();
    var id = $(this).data('id');

    $.ajax({
      type: 'POST',
      url: '<?php echo admin_url( 'admin-ajax.php'); ?>',
      data: {'action' : 'ajax_request', 'id': id},
      dataType: 'json',
      success: function(data) {
        console.log(data['post']);
      }
    });     

    return false;
  });
});

Wednesday, 3 August 2016

Featured image option not displaying in wordpress admin panel

Add this code to the functions.php file of your theme:
// This theme uses post thumbnails
add_theme_support( 'post-thumbnails' );
If you getting this type of issue again please goto wp-admin->add new post-> screen options. At the top of your page you see this screen option open it and check the value featured image if not checked. Now you see the option of featured image in your post page admin side.

Saturday, 16 July 2016

get selected radio button value using jQuery

To get the value of the selected radioName item of a form with id myForm:

$('input[name=radioName]:checked', '#myForm').val()
Here's an example:
$('#myForm input').on('change', function() {
   alert($('input[name=radioName]:checked', '#myForm').val()); 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="myForm">
<input type="radio" name="radioName" value="1" /> 1 <br />
<input type="radio" name="radioName" value="2" /> 2 <br />
<input type="radio" name="radioName" value="3" /> 3 <br />
</form>

Redirect page using jQuery

You can use following methods to redirect a page using jQuery
window.location.replace("http://www.keredari.com");
window.location.href = "http://stackoverflow.com";
$(location).attr('href', 'http://www.keredari.com');
$(window).attr("location","http://www.keredari.com");

Tuesday, 5 July 2016

Setup WordPress Permalinks on Windows IIS

Create a file web.config under root folder where WordPress has installed and past following code. or download from Github.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="wordpress" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

</configuration>