WooCommerce – Fixed quantity of a product [closed]

You might want to reconsider your approach here, at first glance it seems to me that you could greatly simplify this but using a hook after the order is processed. If all of your variations are really only quantities then it stands to reason that when an order is completed you’d update the quantities for … Read more

How to attach a uploaded video to post from front end

You could use wp_insert_attachment to upload a video file into the media library and then attatch it to the newly created post. See http://codex.wordpress.org/Function_Reference/wp_insert_attachment But it would be wise to have a few conditional statements in place to at least check for video size and type otherwise your site would be open to abuse.

child theme inherticance and php autoload

use locate_template() instead. public function load_class( $class ) { $path = str_replace(‘_’, “https://wordpress.stackexchange.com/”, $class); // returns a path when something was found $located = locate_template( $path, TRUE ); return $located ? TRUE : FALSE; } Always return FALSE in an autoloader if you haven’t found the class.

javaScript in section of WP API

Uncaught TypeError: Property ‘$’ of object [object Object] is not a function Are you positive you’re accessing the jQuery object correctly? You should look into how WordPress uses noConflict mode. In the noConflict() mode, the global $ shortcut for jQuery is not available, but you can still use: jQuery(document).ready(function(){ jQuery(#somefunction) … }); As a footnote, … Read more

selected menu item

I definetly suggest you to use WordPress menu feature, is quite easier to implement and you will never need to wory if the user want to rename or add new items. Just add this to your functions.php: register_nav_menus( array( ‘main_menu’ => ‘Main menu’, ) ); Then in header.php or wherever you have the menu add: … Read more

Get ID of child from child slug, while knowing parent ID

You should use the pagename parameter for WP_Query along with post_parent. Limit your query to one post using posts_per_page. $parent_id = get_the_ID(); $args = array( ‘post_type’ => ‘page’ ‘pagename’ => ‘page-2’, ‘post_parent’ => $parent_id, ‘posts_per_page’ => 1 ); $posts = get_posts( $args ); $child = isset( $posts[0] ) ? $posts[0] : false; if( $child ){ … Read more

Recent post display using shortcode

You have missed the quotes in the_permalink(). Use following code function my_recent_posts_shortcode($atts){ $q = new WP_Query( array( ‘orderby’ => ‘date’, ‘posts_per_page’ => ‘4’) ); $list =””; while($q->have_posts()) : $q->the_post(); echo ‘<div class=”item”>’; $title=get_the_title(); if ( has_post_thumbnail() ) { $list .= ‘<a class=”single-image link-icon” href=”‘. get_permalink().'”>’.the_post_thumbnail(array(300,200),array(‘alt’ =>$title)).'</a>’; } $list .= ‘<h6 class=”title”><a href=”.the_permalink().”><span>”‘.the_title().'”</span></a></h6>’; echo ‘<div class=”entry-body”>’; … Read more