Monthly Archives: July 2015

Hide review tabs on woocommerce

functions.php

add_filter( 'woocommerce_product_tabs', 'wcs_woo_remove_reviews_tab', 98 );
function wcs_woo_remove_reviews_tab($tabs) {
 unset($tabs['reviews']);
 return $tabs;
}
Advertisements

Plugin for membership plan with diffrent payment gatway

http://www.paidmembershipspro.com/

https://wordpress.org/plugins/paid-memberships-pro/

For displaying all plans:

[pmpro_levels]

Display Perticular level for signup:

install this plugins adons=>
https://wordpress.org/plugins/pmpro-register-helper/

[pmpro_signup level=”6″ short=”1″ intro=”6″ button=”Signup Now”]

main post under sub posts

functions.php


function trove_custom_init() {
$labels = array(
'name' => __('Treasure Trove','themename'),
'singular_name' => __('trove','themename'),
'add_new' => __('Add New','themename'),
'add_new_item' => __('Add New Treasure Trove','themename'),
'edit_item' => __('Edit Treasure Trove','themename'),
'new_item' => __('New Treasure Trove','themename'),
'all_items' => __('All Treasure Trove','themename'),
'view_item' => __('View Treasure Trove','themename'),
'search_items' => __('Search Treasure Trove','themename'),
'not_found' => __('No Treasure Trove found','themename'),
'not_found_in_trash' => __('No Treasure Trove found in Trash','themename'),
'parent_item_colon' => "",
'menu_name' => __('Treasure Trove','themename')
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'trove' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => true,
'menu_position' => null,
'supports' => array( 'title', 'editor','thumbnail','page-attributes'),
);
register_post_type( 'trove', $args );
}
add_action( 'init', 'trove_custom_init' );

page-template.php


<div class="blog-details single">
<?php
global $post;
$troveargs = array(
'paged' => $paged,
'post_type' => 'trove',
'post_status' => 'publish',
'order' => 'ASC',
'post_parent' => 0
);
$trove_query = new WP_Query($troveargs);

while ( $trove_query->have_posts() ) : $trove_query->the_post();
//if ($post->post_parent == 0) {
?>
<div class="col-md-12 no-padding trovebox">
<h2>
<?php the_title(); ?>
</h2>
<p>
<?php the_content(); ?>
</p>
</div>
<?php
/* Start Second Loop of sub procuct listed under main product */
$troveargs_sub = array(
'paged' => $paged,
'post_type' => 'trove',
'post_status' => 'publish',
'order' => 'ASC',
'post_parent' => $post->ID
);
$trove_query_sub = new WP_Query($troveargs_sub);
while ( $trove_query_sub->have_posts() ) : $trove_query_sub->the_post();
//echo wp_get_post_parent_id( $post_ID );
?>
<div class="col-md-12 no-padding trovebox">
<h4>
<?php the_title(); ?>
</h4>
</div>
<?php endwhile;
/* End Second Loop*/
?>
<?php endwhile; ?>
</div>

display menu item only for registered user

functions.php

add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 );
function add_loginout_link( $items, $args ) {
if (is_user_logged_in() && $args->theme_location == 'primary') {
$items .= '<li><a href="'.get_permalink(74939).'">Documents</a></li>';
}
return $items;
}

media uploader script

functions.php


function legal_framework_load_scripts() {
wp_enqueue_media();
wp_enqueue_script('mymedia-uploader', get_template_directory_uri() . '/js/mymedia-uploader.js', array('jquery'));
}
add_action('admin_enqueue_scripts', 'legal_framework_load_scripts');

mymedia-uploader.js


jQuery(document).ready( function(){
function media_upload( button_class) {
var _custom_media = true,
_orig_send_attachment = wp.media.editor.send.attachment;
jQuery('body').on('click',button_class, function(e) {
var button_id ='#'+jQuery(this).attr('id');
/* console.log(button_id); */
var self = jQuery(button_id);
var send_attachment_bkp = wp.media.editor.send.attachment;
var button = jQuery(button_id);
var id = button.attr('id').replace('_button',"");
_custom_media = true;
wp.media.editor.send.attachment = function(props, attachment){
if ( _custom_media  ) {
jQuery('.mytheme_media_url').val(attachment.url);
} else {
return _orig_send_attachment.apply( button_id, [props, attachment] );
}
}
wp.media.editor.open(button);
return false;
});
}
media_upload( '.mytheme_media_upload');
});

conditional widget

Widget Logic lets you control on which pages widgets appear using WP’s conditional tags. It also adds a ‘widget_content’ filter.

https://wordpress.org/plugins/widget-logic/
Widget Logic

Renaming “Post” to Something Else

Refrence:
http://stackoverflow.com/questions/26145878/renaming-post-to-something-else

functions.php


// Function to change "posts" to "news" in the admin side menu
function change_post_menu_label() {
global $menu;
global $submenu;
$menu[5][0] = 'News Articles';
$submenu['edit.php'][5][0] = 'News Articles';
$submenu['edit.php'][10][0] = 'Add News Article';
$submenu['edit.php'][16][0] = 'Tags';
echo '';
}
add_action( 'admin_menu', 'change_post_menu_label' );
// Function to change post object labels to "news"
function change_post_object_label() {
global $wp_post_types;
$labels = &$wp_post_types['post']->labels;
$labels->name = 'News Articles';
$labels->singular_name = 'News Article';
$labels->add_new = 'Add News Article';
$labels->add_new_item = 'Add News Article';
$labels->edit_item = 'Edit News Article';
$labels->new_item = 'News Article';
$labels->view_item = 'View News Article';
$labels->search_items = 'Search News Articles';
$labels->not_found = 'No News Articles found';
$labels->not_found_in_trash = 'No News Articles found in Trash';
}
add_action( 'init', 'change_post_object_label' );

%d bloggers like this: