wordpress_add

Wednesday, 18 September 2013

With out using Widgets How to get recent post in any page Of WordPress..!!!

Dr-wordpress :This is the method to show the most recent post at any web page of wordpress.

Just paste this code to that File where you want to display the recent POST, Use and enjoy...:).

<?php

     $args = array(
    'numberposts' => 10,
    'offset' => 0,
    'category' => 0,
    'orderby' => 'post_date',
    'order' => 'DESC',
    'include' => ,
    'exclude' => ,
    'meta_key' => ,
    'meta_value' =>,
    'post_type' => 'post',
    'post_status' => 'draft, publish, future, pending, private',
    'suppress_filters' => true );

    $recent_posts = wp_get_recent_posts( $args, $output = ARRAY_A );
?>
 foreach( $recent_posts as $recent ){
  echo '<li><a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' .   $recent["post_title"].'</a> </li> ';
 }

Subscribe Dr-Wordpress for Important Knowledge of wordpress..your's suggestions are most welcomed.

How to style the sub menu in word press Complete code..!!! Dr-wordpress

Here is the exact code to style you sub menu in wordpress.
Before using It just keep in mind the few things.
Note : .menu is the main menu.
           ( you can change it according to your design )

After It Just paste these line to your style Sheet. Than your menu is completely styled Just Change the color and effects according to you web design.. 

.menu
{
width:660px;
height:30px;
float:left;
margin-left:4px;
margin-top:30px;
}



.menu ul, .menu li {
    list-style: none outside none;
    margin: 0;
    padding: 0;
}
.menu li {
  /*  background-image: url("images/sep.gif");*/
    background-position: 0 15px;
    background-repeat: no-repeat;
    float: left;
    margin-left: 5px;
    margin-top: 2px;
    padding-left: 9px;
    position: relative;
}
.menu li.first {
    background-image: none;
    padding-left: 0;
}
.menu li a {
    color: #FFFFFF;
    display: block;
    padding: 8px 5px;
    text-decoration: none;
}
.menu li a:hover {
    color: #A59B00;
    text-decoration: none;
}
.menu ul {
    margin-left: 26px;
    margin-top: 43px;
}
.menu ul ul {
    display: none;
    float: left;
    left: 0;
    margin: 0;
    position: absolute;
    top: 34px;
    width: 150px;
    z-index: 200;
}
.menu ul ul li {
    background: none repeat scroll 0 0 transparent;
    border-bottom: 1px solid #716A00;
    float: none;
    height: auto;
    margin: 0;
    min-width: 120px;
    padding: 0;
}
.menu ul ul li a {
    background-color: #B7AF34;
    color: #FFFFFF;
    display: block;
    height: auto;
    line-height: 1em;
    padding: 5px 10px;
    text-decoration: none;
}
.menu ul ul li a:hover {
    background-color: #D2CA55;
    color: #FFFFFF;
}
.menu ul ul ul {
    left: 100%;
    top: 0;
}
.menu ul li:hover > ul {
    display: block;
}
.menu ul li.current_page_item > a, .menu ul li.current_page_ancestor > a, .menu ul li.current_menu_item > a, .menu ul li.current_page_parent > a {
    color: #A59B00;
}


Subscribe Dr-Wordpress for Important Knowledge of wordpress..your's suggestions are most welcomed.




Tuesday, 17 September 2013

How to Show Post in "Random Order " using Wordpress..!!!


Dr-wordpress : Today i am going to share a method of showing random POST in any word press page..just like QUIZ example or Captacha.You can also use it on different places where you want to show random POST's in wordpress...



wp_reset_query();

   query_posts("post_type=blog&posts_per_page=1&orderby=rand");
 
      while ( have_posts() ) : the_post();
$post_thumbnail_id = get_post_thumbnail_id( get_the_id() ); 
 $url=wp_get_attachment_image_src(  $post_thumbnail_id,"medium" );
?>

     <h1><?php the_title() ?></h1>



Subscribe us for Important Knowledge of wordpress ..your's suggestions are most welcomed.

Using "SLUG" how to get post and page content..!!!

SLUG are used in WordPress ( permalinks structure. ).Basically it is a unique name auto generated by word press. You can also change it...You get specific POST and page content by using slug.It is always in small letters with "-".

For example:

www.abc.com/slug-test

Here is the method to get Slug

<?php 
$slug = get_post( $post )->post_name;
echo $slug; 
?>

Now you have unique name use it and get the specific post and page content by using manual method of POST.


Subscribe Dr-Wordpress for Important Knowledge of wordpress..your's suggestions are most welcomed.

Monday, 16 September 2013

How to add "READ MORE" tag in wordpress Post..??

This the method to To add you "READ MORE" option in word press post or page..

NOTE: (243 is the dummy id)

$post_id2 = 243;
$queried_post2 = get_post($post_id2);
$title2 = $queried_post2->post_title;
echo substr($queried_post2->post_content,0,243);


Subscribe Dr-Wordpress for Important Knowledge of word press..your's suggestions are most welcomed.

How to get current URL at any page..??

This is the method to get URL of current page.Use and enjoy 

$link2=$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] ;

$link_n2=explode('myvar',$link2);


echo $link_n2[1];




Subscribe Dr-Wordpress for Important Knowledge of word press..your's suggestions are most welcomed.


Get page content_in_tempalte..?

This is the method to get content on any template from WordPress edit panel.

<?php 
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> 
         <?php the_content(); ?>
     <?php endwhile; ?>  
   <?php 
endif; ?>


Subscribe Dr-Wordpress for Important Knowledge of word press..your's suggestions are most welcomed.

Friday, 13 September 2013

How to sort Alphabetically in word press..??

 Here is the procedure to sort alphabetically in word press.


$args = array( 'post_type' => 'instructors', 'orderby'=>'title','order'=>'ASC' );


for custom fields:

$args = array( 'post_type' => 'calendar' , 'posts_per_page'    => '-1' ,'meta_key'=>'course_name','orderby' => 'meta_value', 'order' => 'ASC' );

Suggestions are welcomed..


Subscribe Dr-Wordpress for Important Knowledge of word press..your's suggestions are most welcomed.

Thursday, 12 September 2013

Check online That your website is responsive or Not...???

To check that your site is responsive or not visit this link

This is the link,You just paste you URL and check the responsive layout of your website.

http://mattkersley.com/responsive/


Subscribe us for Important Knowledge of word press..your's suggestions are most welcomed..

Tuesday, 10 September 2013

How to get Site URL..?

This is the method to get site URL for example ( www.abc.com/ )
main purpose behind this when you want to add some image or want to fetch some data from server which is present on some Folder than you put this code before that folder.

TO link the logo with main site link we use:
<?php echo get_site_url(); ?>

 Gave directory path of active theme
<?php echo get_bloginfo('template_url'); ?>/ FOLDER-NAME

 

Subscribe us for Important Knowledge of word press.Your's suggestions are most welcomed..

Monday, 9 September 2013

How to make template in word press..??

This is the Php code for make template In word press.

<?php
/*
Template Name:Price Page
 */

After it you may give it your look as you needed..


get_header();   // It is used for get the header file in template just like include in php
get_footer();   // It is used for get the footer file in template just like include in php..

( Note: remember these function enclosed within php tags.)


Subscribe us for Important Knowledge of word press.Your's suggestions are most welcomed..


To allign the content in ( internet Explorer) IE.....

To align the Webpage in IE use these lines for alignment.

<style type="text/css">
body{text-align: center}
div{text-align: left; width: 50em; margin:0 auto; border:1px solid #CCCCCC}
</style>


Subscribe us for Important Knowledge of word press.Your's suggestions are most welcomed..

HOw to Add custom menu in word press..

Locate Function.php and paste this code in it.


function register_my_menus() {
register_nav_menus(
array(
'left-menu' => __( 'Left Menu' ),
'home-menu' => __( 'Home Menu' )
)
);
}
add_action( 'init', 'register_my_menus' );


//Paste this code on any page or template...



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


Here is the code for default menu.Remember don't do styling of <ul>  Make a <div> outside to it and style that div.

example: .div ul {   }

 <?php wp_nav_menu( array( 'theme_location' => 'primary' )); ?>



Subscribe us for Important Knowledge of word press.Your's suggestions are most welcomed..

Custom widget Area In wordpress

Locate functions.php in your active theme folder and add the bellow code in it.


if ( function_exists('register_sidebar') )

    register_sidebar(array(


        'name' => 'recent posts',


'id'=>'recent',


        'before_widget' => '',


        'after_widget' => '',


        'before_title' => '',


        'after_title' => '',


    ));



if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('recent') ) : ?>


     <p>This is what shows when no widgets are added.</p>      


<?php 
endif; ?>



Subscribe us for Important Knowledge of word press.Your's suggestions are most welcomed..


Friday, 6 September 2013

Custom Post type and custom feild in wordpress....

Today We Going to explain the important task that to add custom post in WordPress( including images,files,text etc )


First of all download this plugin

" Simple Custom post type custom field"

Than Add the custom feild where you want to add in your wordpress site.
here is the code to use this plugin on your page.


<?php $data = simple_cck::get_post_data($my_id); //print_r($data);?>

 src="<?php print_r($data['img1']['image_data'][0]); ?>"


<a href="<?php print_r($data['summary']['file']);?>">Click to View</a>



Subscribe us for Important Knowledge of word press.Your's suggestions are most welcomed..

FOR GETTING POST IN ANY WEB PAGE

This is the method to get the selective post (  $post_id = 26; 26 is the id it may be change )

Method 1 <?php
$post_id = 26;
$queried_post = get_post($post_id);
$title = $queried_post->post_title;
echo $title;
echo $queried_post->post_content;
?>



Method 2

<?php // retrieve one post with an ID of 1
query_posts('p=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<h4><?php the_title(); ?></h4>
<?php the_content(); ?>
<?php endwhile;?>

Subscribe us for Important Knowledge of word press.Your's suggestions are most welcomed..

HOW TO GET FEATURED IMAGE IN WORDPRESS

This is the way to get featured image in wordpress..
just paste this code where you want to get featured image in wordpress..


<?php  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );?>
<img src="<?php echo $image[0]; ?>" />


Subscribe Dr-Wordpress for Important Knowledge of wordpress..your's suggestions are most welcomed.

Thursday, 5 September 2013

FQA. when i insert an image from a url..??

When image is inserted From external server.

It doesn't download that image just use the external link.
So image should available only if it is present on that link or server.


Subscribe us for Important Knowledge of word press.Your's suggestions are most welcomed..



How to get the POST of CATEGORY in wordpress

This is the method to get all the post of Respective Category in wordpress.

NOTE : ( cat="1"  is the ID of that category in which post exist It may be change .)


<?php
query_posts('cat=1');
while (have_posts()) : the_post();
the_content();
endwhile;
?>



Subscribe Dr-Wordpress for Important Knowledge of word press..your's suggestions are most welcomed.




How to get theme Directory.?

FOR GETTING DIRECTORIES ( LIKE  PATH OF IMAGES )

<?php echo get_bloginfo('template_url'); ?> 

Example:

<img src="<?php echo get_bloginfo('template_url'); ?> /A.jpg" />


Subscribe us for Important Knowledge of word press.Your's suggestions are most welcomed..