10 Useful One Line Code for WordPress Developers

I have seen mostly wordpress developers which are beginner in wordpress forget most useful one line codes in wordpress like get template url in wordpress or image path in wordpress and much more and using search engine to find them every time so very time taking for a project. then i think why not i am share all Useful One Line Codes only on one place. And here i am discussed with you about 10+ Useful One Line Code for WordPress Developers.

1. Create Widget Area

For creating a widget area in wordpress copy and paste the code in below in your functions.php file

if (function_exists('register_sidebar')) {
     register_sidebar(array(
      'name' => 'Social Widget Area',
      'id'   => 'social-widget-area',
      'description'   => 'Social Widget Area',
      'before_widget' => '<div id="one" class="two">',
      'after_widget'  => '</div>',
      'before_title'  => '<h2 class="widget-title">',
      'after_title'   => '</h2>'
     ));
    }

2. Display Widget Area Content

<?php dynamic_sidebar( 'social-widget-area' ); ?>

3. Create Custom Page Template in WordPress

Create a php file and paste the code below and save this file in your theme directory

<?php
/*
Template Name: My Custom Page
*/
?>

4. Image Path in WordPress

See the code below to give right path to a image in wordpress

<img src="<?php bloginfo('stylesheet_directory'); ?>/images/yourimage.jpg" />

5. Attach CSS File From CSS Directory in WordPress

See the code below and attach your css file like this use same method for javascript.

<link rel="stylesheet" href="<?php bloginfo('template_directory');?>/css/yourcss.css">

6. Display Page Title in WordPress

use the code below to display your page title

<?php the_title(); ?>

7. Register menu in wordpress

Paste the code below in your functions.php file for register menu in wordpress

function register_my_menus() {
  register_nav_menus(
    array(
      'header-menu' => __( 'Header Menu' ),
      'extra-menu' => __( 'Extra Menu' )
    )
  );
}
add_action( 'init', 'register_my_menus' );

8. Display menu on theme

Below code used for display register menu anywhere in your theme

<?php wp_nav_menu( array( 'theme_location' => 'header-menu' ) ); ?>

9. echo Shortcode in Template

use below one line code for echo your plugins shortcodes in template

<?php echo do_shortcode('[shortcode]'); ?>

10. Get Featured Image In WordPress

This code use for display featured image on your template you can change image size using,(thumbnail, medium, large, full)

<?php the_post_thumbnail( 'full' ); ?>

11. Display date & time

<?php the_time('M.d, Y') ?>

12. Display category name

<?php the_category(', '); ?>

The following two tabs change content below.

I hope you enjoyed it and learned something. Do not forget to backup your wordpress before editing any important documents including functions.php, index.php and header.php. That way, if something goes wrong, you have a fresh copy of your website that you know is working. If you would like to share your ideas or comments, feel free to post your comment below.

Myths Of Web Site Design And Development

Web design is a craft that only a few can master. All web designers have to be talented and innovative, but some are more intricately engaged with their vocation than others. On account of an increasingly large number of web designers seeking to get into website design profession, a big array of misconceptions have cropped up. Following is a list of few such myths.

Myth #1: Flash is goodcreative-website-design

Flash is type of software that boosts the aesthetic appeal of a web page but it isn’t indispensable. Adding flash to a web site is not the only way of beautifying it. There are plenty of other ways such as introduction of varied colors, cartoons and pictures that can improve the aesthetics of a site. Furthermore, flash is usually quite a large software that takes a considerable amount of time for being loaded on the page. Hence, the web pages that include flash take some extra time to load. Also, if you include flash in a web site, the designer should provide an option of a non-flash version to users to enable quick transmission of information in case the internet connection of the user is slow.

Myth #2: Lots of colors make the site appealing

Most website design professionals make a vivid use of colors to lend a touch of vivacity to the web pages. However, an over-use of too many colors usually mars the overall impression of a site. It is sensible to make a very careful selection and restrict the usage to a maximum of 3-5 colors per page. A single color may be utilized for highlighting the page hyper-links throughout a website to make it readable.

Myth #3: Images make the site attractive

Web designers recommend the use of images for boosting the overall lure of a website. However, an over utilization of images, cartoons or pictures wrecks the sobriety of the web site, and could be a major put off for the visitors. Moreover, web pages with picture usually take much longer to load. Since the attention span of the site users is very limited, an unnecessary clutter of images and delay in loading pages would likely encourage them to switch instantly over to some other site.

Myth #4: Web pages look the same through multiple browsers

As opposed to the general belief, web sites tend to look different when seen on different browsers. It thus becomes integral for website designers to test and review their sites using different browsers such as Chrome, Firefox, Internet Explorer, etc for ensuring clarity, good resolution and appeal. Nowadays mobile internet has also become common. Hence, designers should also incorporate mobile browsers in their review of the web sites.webdesign_portfolio

Myth #5: It is important to employ professionals for web designing

Obviously, experienced web designers are better versed with the intricacies of web designing than amateurs. However, it does not mean that amateurs cannot learn and handle the tricks of the trade. With due time and continued devotion, amateurs may also try their hand at website designing and development. It is not the forte of professional designers only. If you are a novice and want to design and develop your website, by all means, go ahead and learn how to do it yourself.