Skip to content

Instantly share code, notes, and snippets.

View thagxt's full-sized avatar
🎯
Focusing

ʞↃ∀ɾ thagxt

🎯
Focusing
View GitHub Profile
@thagxt
thagxt / Get Author's name outside Loop in WordPress.php
Last active May 22, 2021 12:28
Get Author's name outside Loop in WordPress
<?php
global $post;
$author_id=$post->post_author;
?>
<?php
/* You can also use one of these instead:
- nickname
- user_nicename
- display_name
@thagxt
thagxt / Test your MySQL connection.php
Last active August 29, 2015 13:58
Test your MySQL connection
<?php
$link = mysql_connect('localhost', 'root', 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected!';
mysql_close($link);
?>
@thagxt
thagxt / WP Get only URL to thumbnail image.php
Created April 3, 2014 14:24
WP Get only URL to thumbnail image
<?php // define ?>
<?php $thumb_id = get_post_thumbnail_id(); $thumb_url = wp_get_attachment_image_src($thumb_id,'steecky', true);?>
<?php // get ?>
<?php echo $thumb_url[0]; ?>
@thagxt
thagxt / Get thumbnail image URI with no http .php
Created April 3, 2014 14:25
Get thumbnail image URI with no http://
<?php
/*
* Wordpress
* Useful when you need to resize an image on the go with; http://i0.wp.com/
*/
?>
<?php // define + trim ?>
<?php
$thumb_id = get_post_thumbnail_id(); $thumb_url = wp_get_attachment_image_src($thumb_id,'steecky', true);
@thagxt
thagxt / AJAX add to cart button on Shop page in WooCommerce.php
Created April 3, 2014 14:27
AJAX add to cart button on Shop page in WooCommerce
WTF: Get the AJAX add to cart button on Shop/Category/Search pages in WooCommerce. (AJAX works only for simple products)
HOW:
1) create a directory, name it "woocommerce" put it in your theme root.
2) copy/pasta from woocommerce plugin directory the content-product.php file
3) at the end of the (content-product.php) file, paste the code below:
<?php
global $product;
echo apply_filters( 'woocommerce_loop_add_to_cart_link',
@thagxt
thagxt / Add to cart button for Variables on Shop page in WooCommerce.php
Created April 3, 2014 14:28
Add to cart button for Variables on Shop page in WooCommerce
WTF: Get the add to cart button on Shop/Category/Search pages in WooCommerce. Not ajax version, works with Variable Products.
HOW:
1) create a directory, name it "woocommerce" put it in your theme root.
2) copy/pasta from woocommerce plugin directory the content-product.php file
3) at the end of the (content-product.php) file, paste the code below:
<?php do_action( 'woocommerce_single_product_summary' ); ?>
<?php do_action( 'woocommerce_after_shop_loop_item' ); ?>
@thagxt
thagxt / Get Magento Latest Products everywhere!.php
Created April 3, 2014 14:29
Get Magento Latest Products everywhere!
<ul>
<?php
$store_id = Mage::app()->getStore()->getId();
$_productCollection = Mage::getResourceModel('reports/product_collection')
->addStoreFilter($store_id)
->addAttributeToFilter('visibility', 4)
->addAttributeToFilter('status', 1)
->addAttributeToSelect('*')
->setVisibility(array(2,3,4))
->setOrder('created_at', 'desc')
@thagxt
thagxt / change email address and name wordpress.php
Created April 20, 2014 18:29
Change default e-mail address and name on outgoing e-mails sent by WordPress.
<?php
// Change default e-mail address and name on outgoing e-mails sent by WordPress.
// code goes in your theme functions.php
// New Email
function sb_new_mail_from( $email ) {
$email = 'info@yoursite.com'; // change
return $email;
}
add_filter( 'wp_mail_from', 'sb_new_mail_from' );
@thagxt
thagxt / Magento How to get the customer login, logout, register and checkout urls.php
Created April 23, 2014 12:10
Magento How to get the customer login, logout, register and checkout urls
login url
<?php echo Mage::getUrl('customer/account/login'); ?>
logout url
<?php echo Mage::getUrl('customer/account/logout'); ?>
My Account url
<?php echo Mage::getUrl('customer/account'); ?>
Register url
@thagxt
thagxt / How to Get the Base Url for a specific Magento Store View.php
Created April 23, 2014 12:25
How to Get the Base Url for a specific Magento Store View
<?php
/*
+ If you want, you can set manually the '$storeId' with the number (id) of the desired store.
+ You can also change 'Mage_Core_Model_Store::URL_TYPE_LINK' with one of these:
- Mage_Core_Model_Store::URL_TYPE_JS
- Mage_Core_Model_Store::URL_TYPE_LINK
- Mage_Core_Model_Store::URL_TYPE_MEDIA
- Mage_Core_Model_Store::URL_TYPE_SKIN
- Mage_Core_Model_Store::URL_TYPE_WEB