Woocommerce custom template - php

As you can see, the title, the placeholder image, the six bottles
image at the top are rendered by the single-product template. I need
it to be rendered by bto-item.php file so that I can edit the CSS, the
contents of it through the template files.
Can you give me the steps to work like that? Currently the select
options are being executed by the Composite product plugin templates.

In your currently used template create new folder named woocommerce and in it put the single product php file. And modify it by your need. :)

Related

How to set woocommerce product image as background image in shop page

I want to replace src="image_url" to style="background: url('image_url')" of product image in shop page.
How should i do this?
Depending on what you are more comfortable, you have 2 possible ways:
in your theme create a folder structure of woocommerce\single-product\, copy inside it the file you can find at \wp-content\plugins\woocommerce\templates\single-product\product-image.php and edit the HTML;
in your theme functions.php add a filter on the woocommerce_single_product_image_thumbnail_html hook and replace the HTML passed by (maybe using some regex)

customize sidebar.php woocommerce bootstrap

I'm looking for a way to customize the woocommerce sidebar. I was able to find the template named sidebar.php but it only contain the get_sidebar('shop') function, but there is no sidebar-shop.php file inside the woocommerce templates folder. I'm not able to customize it to place it on the right side of the screen. I've setted up bootstrap rows and classes for almost all of the main templates files, but also if I set three products per row and col-3, the sidebar will stay to the bottom of the page. I'm using hooks as suggested from docs. Can anyone guide me please?

Wordpress - How to create a custom new page without new php file

I'm creating a custom wordpress template. Usually i create files with the page name, for example if a have a page about, I create a file page-about.php and works fine. And I add acf fields to pages.
But if i want to create a new page with same structure of about pages without create a new php file? How can i do that?
Thank you.
In your question you stated you usually created your custom pages based on the page title, I would recommend you create a custom page template that can be applied to as many pages as needed. You would need to create a .php file along the lines of custom-layout-about.php and put a php comment at the top to let wordpress know it's available.
<?php /* Template Name: custom page layout -- about */ ?>
Then apply your acf fields to target the page template.

Allow page text to be edited from inside the wordpress menu without hardcoding it

New to WordPress theme design, and my google searching is not returning what I am after.
I have a theme I have created and its fine, but the text is all hardcoded into the theme.
I want there to be options in the theme appearance settings? (right place?) where a user can e.g. enter their 'about us' text.
But I have no idea what I should be searching or how to pull in that information into my theme.
Im no a beginner to PHP, but just the way WordPress works itself.
A link, search term or quick start is all I need.
I think you might find the (Free) Advanced Custom Fields plugin useful: http://www.advancedcustomfields.com/
You can add unlimited custom fields and create user interfaces for non-technical people to add content to your theme without them touching any code.
If you set up a field named 'about_text', calling it in your theme would look like this:
<?php the_field('about_text'); ?>
First, you should learn how wordpress is working to display the content. In back office, under Settings > Reading you'll find an option that let you tell how you want Wordpress to deal with the front page : is it a listing of the posts, or a static page?
If you choose the first options, it will use the index.php template from your theme folder. If it's a static page, you'll have to select which page to use for displaying the home (a page you created under the Menu page). The template that will be use then is front-page.php.
For every post / page (page is a post_type, just a variation of post) there will be a title field, a wysiwyg content and a featured image which will be displayed in a template. That's all you can manage by default. To display the title you can use the_title, the content the_content and for the featured image you will need the_post_thumbnail - note that those functions will need to be used inside the loop.
In order to display some more fun, you have many tools at your disposal:
Widgets : widgets are displayed in a sidebar - don't take it literally, it's just a zone of your template. You can register a sidebar with register_sidebar (use this inside your functions.php file, within an init hook). Then in your template you can display the sidebar with dynamic_sidebar.
In WP back office, go then under Appearence > Widgets. You will find your brand new sidebar where you can put any kind of widget you want. If you need a wysiwyg widget, I recommend you to install the Black Studio TinyMCE widget.
Custom fields : any post_type (a post type is an entry in wp_posts) in Wordpress have some associated metas store in wp_postmeta. A meta is defined by a key and a value - it's like any post have an associated array that you can customize.
There is two ways to work with custom fields. First, you can use the default Wordpress feature: when editing a page, click on the screen options button on the top right and enable "custom fields". You will now have a new area to work with on the bottom of the page : you can add fields by name (by default it will list the existing fields names but you can add your own) and value. It's good enough to simple text fields. Then in your template, you can get that value with the get_post_meta function.
The other way is to use a custom fields plugin, which allow you to have wysiwyg fields, loops, media uploader, datepicker... Two popular plugins are Advanced Custom Fields and Custom Field Suite. They both allow you to easily create set of fields for any page / post_type from the back office, and provide their own functions to manipulate fields in templates (but you can still use the WP functions if you want). For example, to get a custom field with Custom Field Suite you do: CFS()->get('my_custom_field').
Custom Post Types : sometimes, custom fields and widgets are not really convenient when you deal with a lot of data with possibly associated pages. In that cases, you can create your own post types just like posts or pages, but you can define which capabilities they have. Use register_post_type to define your new post type (still in init hook), that will make a new section available in your back office, just like posts. Then in your template you can query them with get_posts, the WP function that you will probably the most use when you'll start to play with Wordpress. I suggest you to read the WP_Query documentation in order to learn more about it.
And, at last but not least, you can create your own template that you can associate with any pages. For that, create a php file named whatever you want in your theme folder, paste into it the content from page.php and add this PHP comment on top :
/*
Template Name: My Template
*/
Then choose this template in the dropdown when you edit a page (on the right sidebar).
I think you will have enough to play with, but if you want learn more I recommend you to read about Wordpress hooks and the Widget API to create your own widgets.
Have fun with Wordpress!

Wordpress WooCommerce Product Page Template

I just setup WooCommerce on my wordpress site:
http://artendijen.com/product/test-product/
I am not a fan of the template where it has the description and additional information below and in tabs, I would like the have the description and additional information to the right of the product image. Is there a setting I missed or will I have to edit it via CSS myself?
There is no setting for layout in WooCommerce. If you can do what you need to do with CSS then thats great. Otherwise, you will need to use hooks and actions in your functions.php to move things around. You can also overwrite woocommerce template files by copying them to your template with the same structure and file names you find in the WooCommerce plugin.
http://docs.woothemes.com/document/introduction-to-hooks-actions-and-filters/

Categories