Tag Info

Hot answers tagged

6

An attachment is a Post The posts table contains information on the attachemnt post. In WordPress every uploaded media has it's own post entry, where post_type is 'attachment' and post_status is 'inherit'. In fact, you can get attachment post types using functions used to get other post types, like post, page or any CPT. That include WP_Query, ...


2

If this is a true page, then you can get the ID of that specific page with get_queried_object_id(). This works and will return the ID on the specific pages, single, category, taxonomy, tag and author pages where it is used. True date and time archives and the homepage will not have ID's You can do the following $page_id = get_queried_object_id(); echo ...


2

Do you really need to know the ID, for that see @PieterGoosens's answer, or do you just need to know if you are at the post type product archive? The latter can easily be achieved by using is_post_type_archive(): if ( is_post_type_archive( 'product' ) ) { // code }


1

As per what I understood from your question, you want two things - Listing of all publisher Listing of all books of a particular publisher. Here is code for both. Listing of all publisher $terms = get_terms( 'pa_publisher' ); echo '<ul>'; foreach ($terms as $each_term) { echo '<li>'.$each_term->name.'</li>'; } echo ...


1

Technically speaking, Woocommerce products are just another WordPress post object with a customized post type (which is product in this case). If you take a look at the create_product function inside class-wc-api-products.php, you'll see this line: // Attempts to create the new product $id = wp_insert_post( $new_product, true ); So the API ends up using ...


1

Try this - Add your button inside a form and write down script to add product to the cart and redirect user directly to the checkout page. Suppose, following is the button that you can put on single product page using a WooCommerce hook. <button name="checkout_now"> Checkout Now </button> PHP code: global $woocommerce; $post_id = ...


1

Arrrrg a WooCommerce question... quick burn him at the stake! There's a couple of problems with your callback function above: you are not declaring global $woocommerce so you do not have access to the $woocommerce global variable. and $woocommerce->customer holds the state of the WC_Customer class however this class does not contain a get_role() ...


1

You need to explode the comma separated string to get the array of IDs. Follow the below code. $cookie_array = $_COOKIE["your-results"]; // Test output echo $cookie_array; $cookie_array = array_map( 'absint', (array) explode(',', $cookie_array) ); $sug_args = array( 'post_type' => 'product', 'post__in' => $cookie_array, ); ...


1

Your edit got me to this idea, there indeed is no function called »woocommerce«, there is a class »WooCommerce« though. One thing to be aware of is, that the check has to late enough, so that plug-ins are actually initialized, otherwise - obviously - the class won't exists and the check returns false. So your check should look like this: if ( class_exists( ...


1

Woocommerce stores 'order' metakeys in the table wp_woocommerce_termmeta. The mechanism it uses is the same as menu_order for posts. Check this thread for reference. Thanks


1

First is showing the attachment file path, second is file attributes size, type, height, width etc. Thanks attachment in wp_post shows the attachment basic details title, time, author etc. wp_postmeta shows attachment all other details for example attachment would be text, pdf, image etc so it having different meta data for different types of posts. ...


1

This will definitly remove word category . Add this code in functions.php.As you already know woocommerce_template_single_meta is the hook responsible for meta information of the single-product. File is present in /woocommerce/templates/single-product/meta.php. Either you can use the following code to edit the html of meta.php or you can copy the file ...


1

Here was the problem. I just didn't add the <?php wp_footer(); ?> in my footer.php file. so simple but important. I guess woocommerce group should check if wp_footer() doesn't exists add the scripts in header instead because I have wp_head() set up in my header.php



Only top voted, non community-wiki answers of a minimum length are eligible