Thu 14 Nov |
|
Wordpress Cheat SheetHere's a list of Wordpress code snippets so that I don't have to search the forums every time I need one! Permalink<?php the_permalink(); ?> Is front pageis_front_page()....................................................... Get home page urlget_home_url()....................................................... Get the current post IDget_the_ID()....................................................... Get the current category ID$category = get_the_category();$catid = $category[0]->cat_ID; ....................................................... Get the current title and printthe_title()....................................................... Get the current title as stringget_the_title()....................................................... route to template folder in files<?php bloginfo( 'template_directory' ); ?>....................................................... static home pageSettings->Reading->Front page displaysmust be 2 different pages .. blog can be dummy blank page ....................................................... shortcode in template files<?php echo do_shortcode("[slider id='42' name='Boswell' size='full']") ?>must be 2 different pages .. blog can be dummy blank page ....................................................... Wordpress Woocommerce
PermalinksShop<?php get_permalink( woocommerce_get_page_id( 'shop' ) ) ?> ....................................................... Category <?php get_term_link( 21 ,'product_cat') ?> ....................................................... Product - is just a post <?php get_permalink( '1087' ) ?> ....................................................... My Account <?php $myaccount_page_id = get_option( 'woocommerce_myaccount_page_id' ); if ( $myaccount_page_id ) { $myaccount_page_url = get_permalink( $myaccount_page_id ); } ?> ....................................................... Cart <?php global $woocommerce; $cart_url = $woocommerce->cart->get_cart_url(); ?> ....................................................... Payment Page - typically /checkout/pay/ <?php $payment_page = get_permalink( woocommerce_get_page_id( 'pay' ) ); // make ssl if needed if ( get_option( 'woocommerce_force_ssl_checkout' ) == 'yes' ) $payment_page = str_replace( 'http:', 'https:', $payment_page ); ?> ....................................................... Logout <?php $myaccount_page_id = get_option( 'woocommerce_myaccount_page_id' ); if ( $myaccount_page_id ) { $logout_url = wp_logout_url( get_permalink( $myaccount_page_id ) ); if ( get_option( 'woocommerce_force_ssl_checkout' ) == 'yes' ) $logout_url = str_replace( 'http:', 'https:', $logout_url ); } ?> ....................................................... |
Last Updated on Thursday, 09 November 2017 14:44 |