Skip to content

Instantly share code, notes, and snippets.

View filipvanreeth's full-sized avatar

Filip Van Reeth filipvanreeth

View GitHub Profile
function wb_get_title( $before = '<h1>', $after = '</h1>' ) {
$title = NULL;
if ( is_page() || is_singular() || is_single() ) {
$title = get_the_title();
} elseif ( is_archive() ) {
$title = $category_name = single_cat_title( '', false );
} elseif ( is_post_type_archive() ) {
$obj = get_queried_object();
$title = $obj->labels->name;
} elseif ( is_tax() ) {
@filipvanreeth
filipvanreeth / woocommerce_get_woocommerce_page_ids.txt
Last active November 29, 2016 12:50
WooCommerce - Get WooCommerce Page IDs
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
get_option( 'woocommerce_terms_page_id' );
@filipvanreeth
filipvanreeth / Whity-page.php
Last active December 5, 2016 14:17
Whity Page - Show a different front page if the user is not logged in
<?php
/*
Template Name: Whity Page
Show a different front page if the user is not logged in. In this case we use a white page without any content.
*/
$frontpage_id = get_option( 'page_on_front' );
$get_page_template = get_post_meta( $frontpage_id, '_wp_page_template', true );
// Set template name (ex.page-whity.php);
$template_name = 'page-whity.php';
@filipvanreeth
filipvanreeth / function.php
Created October 2, 2017 05:29
Remove admin menu pages with 5 lines of code
function disable_admin_menu_pages() {
// Check if the plugin exists and is active
if ( class_exists( 'Woocommerce' ) && is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
// Set a user capability to disable the menu pages. In this case the menu pages will be removed for all users who don't have the 'manage_options' capability.
if ( ! current_user_can( 'manage_options' ) ) {
remove_menu_page( 'woocommerce' ); // Remove the WooCommerce menu page
remove_menu_page( 'edit.php?post_type=product' ); // Remove the products menu page.
}
}
}
@filipvanreeth
filipvanreeth / SassMeister-input-HTML.html
Last active July 23, 2018 07:22
Generated by SassMeister.com.
<h1 class="u-margin-4 u-margin-2-lg">Dit is een tekst</h1>
@filipvanreeth
filipvanreeth / wp_query_category.php
Created September 18, 2017 08:26
Get category title and posts through WP_Query
<?php
$args = array(
'cat' => set_your_id,
'posts_per_page' => set_your_posts_per_page_ex_5,
);
// Get the category object with properties
$category = get_category( $args['cat'] );
// Define WP_Query withe the arguments
$query = new WP_Query( $args );
?>