How to render custom html in tabs block

Remove _prepareForm() function from your Tab block and add constructor as shown below

class Company_Module_Block_Adminhtml_CustomSettings_Edit_Tab_Settings extends Mage_Adminhtml_Block_Widget_Form
{

    public function __construct()
    {
        $this->setTemplate('MODULE_NAME/customsettings/view.phtml');
    }

}

Create a view.phtml file at design/adminhtml/default/default/template/MODULE_NAME/customsettings

Create custom WordPress form and handle submission?

<?php

/**
 * Plugin Name: Custom Form
 * Plugin URI: http://http://tahiryasin.wordpress.com/
 * Description: Creates a custom form through shortcode and handles the submit event.
 * Version: 1.0
 * Author: Tahir Yasin
 * Author URI: http://tahiryasin.wordpress.com/about/
 * License: GPL2
 */

class CustomForm
{

    public function __construct()
    {
        add_action('init', array($this, 'init'));
        add_shortcode('custom_form', array($this, 'shortcode'));
    }

    public function init()
    {
        if (!empty($_POST['nonce_custom_form']))
        {
            if (!wp_verify_nonce($_POST['nonce_custom_form'], 'handle_custom_form'))
            {
                die('You are not authorized to perform this action.');
            } else
            {
                $error = null;
                if (empty($_POST['name']))
                {
                    $error = new WP_Error('empty_error', __('Please enter name.', 'tahiryasin'));
                    wp_die($error->get_error_message(), __('CustomForm Error', 'tahiryasin'));
                }
                else
                    die('Its safe to do further processing on submitted data.');
            }
        }
    }

    function shortcode($atts)
    {
        return "<form method='post' action=''>
    <input name='name' type='text' value='' />
    " . wp_nonce_field('handle_custom_form', 'nonce_custom_form') . "
        <input type='submit' value='Submit'/>
    </form>";
    }

}

$CustomForm = new CustomForm();
?>

Get custom attribute value in Magento

Simplest way:

echo $_product->getAttributeText('custom_attribute_code');

Problem:

You will get a fetal error if the attribute is not already registered.

Fatal error: Call to a member function getSource() on a non-object in D:\..\app\code\core\Mage\Catalog\Model\Product.php on line 1389

Solution:

$attribute = $_product->getResource()->getAttribute('custom_attribute_code');
if ($attribute)
{
	echo $attribute_value = $attribute ->getFrontend()->getValue($_product);
}

This code will first check if the attribute code exists and gets its value if its there.

Multi Image Upload

Multi Image Upload adds a meta box to upload multiple images for posts and pages. You can enable it for custom post types also.

Installation:

  1. Upload plugin to the `/wp-content/plugins/` directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. To retrieve linked images [Use miu_get_images()](http://wordpress.org/extend/plugins/multi-image-upload/other_notes/#miu_get_images()) into the loop to get an array of image URLs
  4. Optional

If you need to enable this meta box for your custom post type for example ‘book’. Just edit the multi-image-upload.php as shown below

Replace:

$this->post_types = array('post', 'page');

With:

$this->post_types = array('post', 'page', 'book');

Usage

$images = miu_get_images($post_id); 

//Sample output
Array
(
    [0] => http://www.example.com/image-1.png
    [1] => http://www.example.com/image-2.png
)

?>

Screenshots:

screenshot-1

screenshot-2

screenshot-3

WordPress advanced search filters based on custom fields

<?php
/**
 * Template Name: Search
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 * @since Twenty Eleven 1.0
 */
get_header();

$fields = array('country', 'state', 'zip', 'min_age', 'max_age');
foreach ($fields as $field)
{
    if ($_REQUEST[$field] != '')
    {
        if ($field == 'min_age')
        {
            $meta_query[] = array(
                'key' => $field,
                'value' => $_REQUEST[$field], // This is OK, WP_Query will sanitize input!
                'compare' => '>=',
            );
        } elseif ($field == 'max_age')
        {
            $meta_query[] = array(
                'key' => $field,
                'value' => $_REQUEST[$field], // This is OK, WP_Query will sanitize input!
                'compare' => '<=',
            );
        }
        else
        // We have something to match, otherwise ignore the field...
            $meta_query[] = array(
                'key' => $field,
                'value' => $_REQUEST[$field], // This is OK, WP_Query will sanitize input!
                'compare' => '=',
            );
    }
}
$args = array(
    'post_type' => 'vendor',
    'category__in' => $_REQUEST['category'],
    'posts_per_page' => -1, // -1 to display all results at once
    'order' => 'ASC',
    'meta_query' => $meta_query,
);
$query = new WP_Query($args);
?>
<div id="primary">
    <div id="content" role="main">
        <?php if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post();
                ?>
                <div class="post">
                    <?php the_title(); ?>
                </div>
                <?php
            endwhile; //end of the loop
        endif;
        ?>
    </div><!-- #content -->
</div><!-- #primary -->

<div id="secondary" class="widget-area" role="complementary">
    <form method="get">

        <label for="country">Country:</label>
        <input type="text" name="country" value="" />

        <label for="state">State: </label>
        <input type="text" name="state" value="" />

        <label for="zip">Zip: </label>
        <input type="text" name="zip" value="" />

        <label for="min_age">Min Age:</label>
        <input type="text" name="min_age" value="" />


        <label for="max_age">Max Age: </label>
        <input type="text" name="max_age" value="" />

        <label for="category">Category:</label><br />
        Category 1<input type="checkbox" value="5" name="category[]" /><br />
        Category 2<input type="checkbox" value="6" name="category[]" /><br />
        Category 3<input type="checkbox" value="7" name="category[]" /><br />
        Category 4<input type="checkbox" value="8" name="category[]" /><br />
        <input type="submit" value="Search" />
    </form>
</div>

<?php get_footer(); ?>