Month: June 2017

wordpress

How to Create Custom Single Post Templates in WordPress

if we have a custom post type “Food” with slug “food” Then we can create single page specific to this custom posts as: single-food.php

wordpress

Custom Post Type pages are “not found”

Save your permalinks once again and check the pages.

Jquery & Javascript

Uncaught TypeError: Cannot read property ‘className’ of null

This error occurs because we called a class or id that is not defined inside the body tag in html , or its div is not defined in a proper way. Actually div is not existed, there is no element html elements. So check the code and correct the error.

HTML Jquery & Javascript

Submit a form using javascript

We can submit a form using its name, id, class and tag <form id=”form” name=”form1″ class=”form”> </form> Suppose forms name is “form1”, then we can submit the form with jquery as below: $(“form[name=’form1′]”).submit();

wordpress

Get value from option tree wordpress

option tree with field id “facebook_url” then: <?php if ( function_exists( ‘ot_get_option’ ) && $test_input = ot_get_option( ‘facebook_url’ ) ) { ?> <a href=”<?php echo $test_input;?>” target=”_blank” ><img  class=”push” src=”<?php bloginfo(‘template_directory’)?>/images/facebook.png” alt=”facebook” />  </a> <?php } ?>

wordpress

Calling timthumb image url for featured image in wordpress

Include timthumb.php file in theme directory. Instead of post thumbnail image calling add following code: <?php if ( has_post_thumbnail() ) { $thumb_id = get_post_thumbnail_id(); $thumb_url = wp_get_attachment_image_src($thumb_id,’thumbnail-size’, true); ?> <a href=”<?php the_permalink(); ?>” ><img src=”<?php bloginfo(‘template_directory’)?>/timthumb.php?src=<?php echo $thumb_url[‘0’]; ?>&q=100&h=125&w=230″ alt=”” /></a> }

wordpress

Calling registered menu in wordpress

Suppose we register a menu using  register_nav_menus function in php with a id ‘header_Menu’,  , then we can call the menu as below <div id=”menu”> <ul id=”dropmenu”> <?php wp_nav_menu( array( ‘container’ => false, ‘theme_location’ => ‘header_Menu’, ‘items_wrap’ => ‘%3$s’ ) ); ?> </ul> </div>

wordpress

Upload file size increase using function.php in wordpress

Add following filter in functions.php function upload_size_limit_wp( $size ) { return 1536000*14; //Your Size in kb } add_filter( ‘upload_size_limit’, ‘upload_size_limit_wp’);

wordpress

Option tree tree settings hiding from the wordpress backend

Add following code in functions.php add_filter( ‘ot_show_pages’, ‘__return_false’ );

wordpress

Meta generator removing from wordpress

Add following code in function.php remove_action(‘wp_head’, ‘wp_generator’);

Load More