Updates from January, 2013 Toggle Comment Threads | Keyboard Shortcuts

  • saif 7:55 am on October 10, 2012 Permalink | Reply
    Tags: featured image, post thumbnail,   

    WordPress ‘Featured Image’, how to use… 

    WordPress stands for most common and popular CMS now a days. Sometimes we need just a media field for a image to be added in a post. WordPress latest 3+ version has this facility, so you don’t need to use any ‘custom field type’.

    In default theme, this feature enabled by default, but when you are using a custom made theme or a theme of your choice which you downloaded, but not supported ‘featured Image’ section, then what to do.

    Its very simple for wp developer to add that support to your theme. Add below code to your theme’s functions.php file :

    add_theme_support('post-thumbnails');

    Now you will see that section in your admin sidebar when adding/editing any page/post. And also you will find option at your ‘Screen Options’ section as below, so from there you can enable/disable that for future need.

    In right sidebar, ‘Featured Image’ section after adding a image:

    Now, You knew how to add theme support and how to add an image on admin panel. So to show this image on front-end, in any single post/page or in any loop, just add below code to show it between wp post loop:

    <?php the_post_thumbnail();?>

    This will show that image as you added in admin panel with that image ratio. Note that this code will execute when you are using wordpress’s default loop code like <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> and <?php endwhile;  ?>

    If you use custom loop code using other function like get_posts() or custom query like $wpdb->get_results(), then it depends on that way and you have to pull data with correspondence format.

    Use, modify and share your thoughts and happy blogging 🙂

     
  • saif 8:49 am on April 27, 2012 Permalink | Reply
    Tags: excerpt, how to, pages,   

    Add Page Excerpt Option in WordPress Admin Panel 

    WordPress is not a blogging platform now, has many other features, options, resources, plugins to fulfill your requirements.

    In some wp version(like 3.1), for ‘pages’, no ‘excerpt’ option, even not option in ‘Screen Options’ to display it . So an easy way to add this to your wp admin panel, follow below steps:

    add the following code to your functions.php file.

     //Add Excerpts to Pages 
    function themeprefix_add_page_excerpt_support() {
     add_post_type_support( 'page', 'excerpt' ); 
    } 
    add_action('init', 'themeprefix_add_page_excerpt_support'); 

    We have done this excerpt option by a wordpress hook. At first we used add_post_type_support function to use a specific post type option then we packed within a function. And this function called by a worpress hook/filter to make it available for admin panel.

    Functions.php is found in “wp-content\themes\[your-currently-active-theme]\”.

    Cheers 🙂

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel
%d bloggers like this: