Pages

Saturday, December 22, 2012

Getting Tags,Categories by Post Type Wordpress/get_terms shows empty array

Recently I faced an Issue of getting tags of a Custom Postype created by Me and I solved it as follows
I registered a taxonomy for the same as follows

For Tags
register_taxonomy(ad_tag,
            array('my_cust_posttype'),
            array('hierarchical' => false,
                  'labels' => array(
                        'name' => __( 'Ad Tags', 'appthemes'),
                        'singular_name' => __( 'Ad Tag', 'appthemes'),
                        'search_items' =>  __( 'Search Ad Tags', 'appthemes'),
                        'all_items' => __( 'All Ad Tags', 'appthemes'),
                        'parent_item' => __( 'Parent Ad Tag', 'appthemes'),
                        'parent_item_colon' => __( 'Parent Ad Tag:', 'appthemes'),
                        'edit_item' => __( 'Edit Ad Tag', 'appthemes'),
                        'update_item' => __( 'Update Ad Tag', 'appthemes'),
                        'add_new_item' => __( 'Add New Ad Tag', 'appthemes'),
                        'new_item_name' => __( 'New Ad Tag Name', 'appthemes')
                    ),
                    'show_ui' => true,
                    'query_var' => true,
                    'update_count_callback' => '_update_post_term_count',
                    'rewrite' => array( 'slug' => $tag_tax_base_url, 'with_front' => false ),
            )
    );

For Categories
    register_taxonomy( APP_TAX_CAT,
            array(APP_POST_TYPE),
            array('hierarchical' => true,
                  'labels' => array(
                        'name' => __( 'Ad Categories', 'appthemes'),
                        'singular_name' => __( 'Ad Category', 'appthemes'),
                        'search_items' =>  __( 'Search Ad Categories', 'appthemes'),
                        'all_items' => __( 'All Ad Categories', 'appthemes'),
                        'parent_item' => __( 'Parent Ad Category', 'appthemes'),
                        'parent_item_colon' => __( 'Parent Ad Category:', 'appthemes'),
                        'edit_item' => __( 'Edit Ad Category', 'appthemes'),
                        'update_item' => __( 'Update Ad Category', 'appthemes'),
                        'add_new_item' => __( 'Add New Ad Category', 'appthemes'),
                        'new_item_name' => __( 'New Ad Category Name', 'appthemes')
                    ),
                    'show_ui' => true,
                    'query_var' => true,
                    'update_count_callback' => '_update_post_term_count',
                    'rewrite' => array( 'slug' => $cat_tax_base_url, 'with_front' => false, 'hierarchical' => true ),
            )
    );

And Then I retrieved Tags for my custom post type as
$mylinks_tags = get_terms('ad_tag','orderby=name&hide_empty=0');

remember the parameter hide_empty if you are starting afresh you will get an empty array if this is not set to 0 by default this is 1 which means all empty terms will be hidden.Scratched my head for a couple of hours to figure this out

Saturday, December 15, 2012

Wordpress Theme Not Updating Or Cache Issue

Wordpress Theme Not Updating Or Cache Issue:

Sometimes we get a wordpress installation and have to work on the same.I recently faced this theme not updating issue when I had to customize the functionality of a Preinstalled theme by creating a child theme from the same.


If you installed WordPress yourself and you did not install a cache plugin then WordPress itself is not caching. If you are you using a preinstall then check the plugins to look for anything that could resemble a caching plugin. One of the better known one's is WP Super Cache for example.


Firefox Caching: Get latest page every time

Firefox Caching
Get latest page every time


Internet Explorer has a fantastic Web Cache option in Tools > Internet Options > Browsing History > Settings > called “Check for newer versions of Stored Pages:’. This option lets you override Internet Explorers smart caching option.
This is useful when you’re visiting websites that frequently have changing, dynamic data, but their meta tags or HTTP Content headers don’t tell your browser to get a new copy of the page every time. All you have to do is switch the setting to “Every time I visit the webpage“.
To access it in Firefox, simply enter this into your URL location box:
about:config
Then find the browser.cache.check_doc_frequency and change it to 1. This will force Firefox to check for a newer version of the page you’re viewing, regardless of the servers instructions, or Firefox’s default settings.
This is useful because by default Firefox is set at 3 which means that it will always used an old, cached version of the web page, unless the server specifically indicates a newer one is available. You never know if you’re getting the right stuff.
For reference, valid values for browser.cache.check_doc_frequency are:
0 – Check for a new version of a page once per session (a session starts when the first application window opens and ends when the last application window closes).
- Check for a new version every time a page is loaded.
2 – Never check for a new version – always load the page from cache.
3- Check for a new version when the page is out of date. (Default)




Friday, December 14, 2012

Remove Wordpress Toolbar/Panel from top

To remove wordpress toolbar/panel from top use the following code in functions.php of your template

add_filter( 'show_admin_bar', '__return_false' );
To remove the faint line, go into white.css, find the block:


#header {
 background-color:transparent;
 background-image:none;
 border-bottom:1px solid #E5E5E5;
}
and remove the line border-bottom:1px solid #E5E5E5;

Thursday, December 13, 2012

Buddypress-User registration is currently not allowed

Buddypress Error:

Buddypress Error:User Registration is currently not allowed on registration page is simple caused because Membership for anyone is disabled in wordpress.

To resolve this issue simple do 1 thing

In admin panel go to

Settings->General

and in front of Membership section check mark "Anyone can register Check box"

Tuesday, December 11, 2012

Oscommerce Add products to cart manually

In order to add products manually by Id or customize cart manually in OSCommerce

we need to first include the following file

require("includes/application_top.php")

What  this does is automatically includes the following class

require(DIR_WS_CLASSES . 'shopping_cart.php');(line 126)

and instantiates an object of class

if (!tep_session_is_registered('cart') || !is_object($cart)) {
    tep_session_register('cart');
    $cart = new shoppingCart; 
} 
or you can yourself include these files and create an object
But for any action in oscommerce I prefer to include application_top.php
If you are building up a new cart add
$cart->reset();
This will reset your cart which is only required if you are planning to add a new cart in my case I was sending all Items from another website to my oscommerce website so I decided to reset cart first

Now let us suppose we have item information in an array $items

foreach($items as $item)
{
       $attributes = isset($HTTP_POST_VARS['id']) ? $HTTP_POST_VARS['id'] : '';
       $cart->add_cart($item['id'],$item['quant'],$attributes);
      //In case cart is not empty and you want to add quantity to an item
      $cart->add_cart(
$item['id'], $cart->get_quantity('$item['id']')+1);
}

Then add the following lines
//Cleans any product with quantity zero
$cart->cleanup();
//Calculates the weight and total cost in all finalizes your cart
$cart->calculate();

That's All

Associate a file extension with a language in notepad++

Select Settings and then Style Configurator and you will get a window as follows


 Add a file type as shown above for example I have added ctp User extension to link cakephp ctp extension as a php file

Sunday, December 9, 2012

Hiding Controller from cakephp Url

In routes.php add the following code

  Router::connect('/*', array('controller' => 'Site', 'action' => 'display'));

What this does is each time you fire a url with "/parameter" it redirects to Site controller and display action

Now under site controller in display action add this

class SiteController extends AppController
{
    public $name="Site";
   
    public function display()
    {
        $path = func_get_args();
        //print_r($path);
        $count = count($path);
        if (!$count)
        {
             $this->redirect('/');
        }
        else
        {
            $this->render(implode('/', $path));
        }
    }
}