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.