How to create a second header for woocommerce - wordpress

I want to create a second header. One to implement in all pages of Woocommerce. The other one on the other pages of Wordpress. How can I write the code?
get_header('shop'); get_header('shop2');

There are few steps to do that:
- Duplicate your header.php file and name it header-{smth}.php. Replace {smth} with word that you want. For example: header-shop2.php
- Now you can call get_header('shop2')
Reference:
https://www.webascender.com/blog/create-multiple-headers-footers-wordpress/

Related

Changing the "standard template" name of the single.php post template

I have a Wordpress website, now i want to change the post template name how it displays in the Wordpress CMS. Now it's saying "Standard template", i want to rename this to "News", just for usability reasons.
I can't find a way to do this. I know you can create new post templates by creating new files, but it always takes the single.php as standard template. I'm also using a child-theme, so i dont want to delete the single.php file, just rename the text: "Standard template".
Thanks in advance.
I tried creating a new post template file with a custom title. This doesnt solve problem, as the single.php file will still be the standard one (i dont want the user to have to change the template).
You can use another single.php for another post type for example if you have news registered as a post type you could have a single-news.php and that file then would server all the single views of postype = news. But from what i understand you would like to create a template appearing to the user with a different name. For that the best practice is to create a directory inside your child theme and name it page-teplates. Inside this directory you can create as many different templates you want and wordpress will recognize them but adding the following code at the top of each template. For the sake of the example lets say i want to create a contact page template. I will create a contact.php file inside the directory page-templates and have these lines of code inside.
<?php
/**
* Template Name: Contact
**/
get_header();
/* My templates Code/Design Here */
get_footer();
The possibilities are endless.
The code in this post will generate a dropdown box similar to the one that you see in pages.
All it requires is a little editing of your child themes functions.php file .
In most cases, you just need to copy your single.php file to a new file name in your child theme and edit the functions.php file in your child theme. Name your templates as seen in the code Dimitrios posted.
consider using the premium elementor page builder to create custom post templates that you can apply at will.
Try a plugin like Post Custom Templates Lite

Display the same author name for all users in WordPress?

For a Wordpress organization website, I want all the posts to have by default the same author name (the organization name). How can I achieve this behavior?
There are multiple possibilites.
1) Simplest: You only create one author and share the login within the organization
2) You simply do not display the author on your post - why would you do that? It is probably obvious that your organization is the publisher of these pages anyway.
3) Add the following custom code within your Theme or Plugin:
add_filter('the_author','its_my_company');
function its_my_company() {
return 'Organization Name';
}
https://developer.wordpress.org/reference/hooks/the_author/
Your best best is to modify your theme or child theme to display a specific user or name wherever the template does so. In your single.php file, look for the_author() or get_the_author(). Then use something like get_user_by() to pull a specific user, or else hard code the value (less ideal, but an option).
Your other option is to manually set it each time, which I could exactly define as making anything "default." Even so, the option exists.

Is it possible to create a custom page and use WordPress Codex?

I want to ask that can I create a file with my favorite name and use WordPress Codex in it ? How I can do that ? I want to load posts of a unique category in it ...
Note: I don't want to create a Page from WP Dashboard.
Thanks !
It will be better to create a page template and write the code for displaying post from category. Then assign your template to any of the Page in Wordpress Dashboard.
Look at the Wordpress Template Hierarchy
To load posts of a unique category (e.g. movie_cat) you can create a file named category-movie_cat.php.
Click here for a larger version of this picture
If you want to create a new php file which will work with your WordPress install, create your new file and copy/paste this piece of code, name this file like you want:
define('WP_USE_THEMES', false);
/** Loads the WordPress Environment and Template */
require ('wp-blog-header.php');
Correct the path for wp-blog-header.php according to where your new file is placed (in this example, the file is at the same level of wp-blog-header.php).
Add your special script to this page and you're done !
Note that this method is a way to display your content in another way than the activated theme. If you want to add function in your plugin or theme, you only need to include it in your functions.php or main plugin file to use WordPress functions, db...
Hope it helps

Identify wordpress blocks

I am trying to edit a wordpress-theme (translations that are hardcoded in the theme etc) and stumble upon a problem here:
How do I identify, where a content block comes from?
Like, if my theme is constructed by 3 files post.php header.php and footer.php (which would make things pretty simple, but in my case it's quite some more files) and the content isn't set there consistently and the naming is neither "semantic", how could I identify that compiled block abc comes from header.php?
Is that something that can be done via Firebug/DevTools?
Although this question is specifically aiming at Wordpress as a system, the same problem occurs with other file-heavy systems like Typo3 or Magento. Isn't there some other routine then opening, searching all existing files?
Thanks for your answers
If your theme is translation-ready, you could try using Poedit. If not, you can identify where a block comes from knowing that:
Header.php: you'll find there all the strings that come in every page of your blog. Normaly Header.php includes all the code from the beginning of the HTML document until body, but it can be different from one theme to another. There may be diferrents headers, like header-gallery.php (for galleries) or similars.
Index.php: That's the index of your blog, normally it includes the code from the BODY of the html document for the index page.
Single.php, Page.php, Content.php, Aside.php or similars: They include the code for the body of every post/page type. For instance, single.php includes the BODY code for the single post. Sometiems, instead of single.php there are another options like content.php, content-wide.php or similars ("content-TypeOfPage.php"
Footer.php: It closes the HTML document for every post/page. Normaly it includes from the last lines before closing the BODY until the closing of the HTML tag.
Functions.php:: Take care editing this one. This file and the other files required/included on it include the code for the settings of the theme and any other functions implemented. For instance, the custom admin pages on the Dashboard are coded there.

Want to set wordpress website's page title

In My wordpress website's page titles are start with >> symbol I want to remove that >> symbol so please help me..
and I'm using wordpress-seo plugin after that this problem is occuring
You have to modify your theme to do that.
Most likely you have to modify the header.php file using the wordpress theme editor.
Find the line where wp_title is called and call it with an empty string as first parameter.
When wp_title is called without any parameters it adds the leading » (») by default.
You can also trim the result of wp_title to avoid leading and trailing whitepspace.
Take a look at the following links too:
http://www.onlinenerd24.de/2008/09/29/remove-the-from-your-wordpress-title/
http://cuongdang.info/how-to-remove-the-arrows-%C2%BB-from-wordpress-titles.html
http://codex.wordpress.org/Function_Reference/wp_title (take a look at the $sep param)

Resources