I need to redirect the user to a specific page by placing a hyperlink just before a closing </ul> tag (which is within a WordPress sidebar widget).
An example of what I am trying to achieve can be found below, using the WooCommerce Products widget which has been slightly modified to include an additional Specials hyperlink:
I am using the WooCommerce 2.9.1 plugin, and believe that the file I need to modify is the
class-widgets-products.php file. This file is made up with the following code - http://pastebin.com/vgpSqa6X.
On line 178 I have placed the following, which will display a hyperlink taking the user to a Specials page on the website:
echo '» Specials';
However, with this particular widget, it creates three separate instances and this will apply the hyperlink to All Products, Featured Products and On-sale Products.
How can I create separate hyperlinks that will apply to the widget, depending on which option has been selected in the admin menu?
For example, if the Featured Products option has been selected, it will output a Featured Products hyperlink at the bottom, and if the On-sale option has been selected, it will output a Specials hyperlink at the bottom.
Thank you.
The answer seems to lie in :
$this->settings->show->options
or :
$this->settings['show']['options']
...as the code you have pasted suggests.
Just evaluate this value with if's (or switches, whatever you feel comfortable with) :
if ($this->settings['show']['options'] == "this_particular_kind")
{
$link_at_the_bottom = '» This Particular Kind';
}
...
Related
I purchased a WP theme https://themeforest.net/item/pressville-municipal-wordpress-theme/19949423 and need to add general content area to the People page: https://preview.themeforest.net/item/pressville-municipal-wordpress-theme/full_screen_preview/19949423?_ga=2.67243158.624148492.1570058772-1881232054.1569979687
The People page is actually a section in the WP dashboard (kind of like Media or Portfolio section) so technically not a editable page in the WP backend. I contacted the theme creator and was told that it's customization (not included w/theme) and advised to hard code text into the php. The problem with that is it's not accessible to other users who have no design or code background.. Is there a way to create a page with editable content block for this People section so it's easily editable without knowing code?
Also, the “People” header text changes if you click on subcategories (to “Elected Officials”) for example. When you click a subcategory, the main menu (People page) no longer shows as active which can be confusing to users. Is there a way to fix this so header stays consistent (like Contact page header) and menu item shows active regardless of what subcategory(All, Elected Officials, etc) is selected on the People page? Thanks.
You can create a regular page called "People's page" and add text to it. Then if you want to show that page's content into a PHP template you can do the following:
Step 1. Create the Function
Open up your theme’s functions.php file and paste the following code, likely at the bottom of the page.
function cn_include_content($pid) {
$thepageinquestion = get_post($pid);
$content = $thepageinquestion->post_content;
$content = apply_filters('the_content', $content);
echo $content;
}
Step 2. Use the Function in a Template File
Next, open up the specific template file you want to include the Page’s content on and paste in the function:
<?php cn_include_content(31); ?>
Replace 31 with the ID of the Page you want to include. How to find a page ID.
Is sounds like you need to go to your wp-admin and click appearance/ menus. Here you can remove these menu items that might be default but have no pages associated with them. You can then add the pages you want and come back and create a custom menu. Hope that answers the first part of your question.
i got in stuck with a customization that i want to do on myaccount navigation menu in the Woocommerce account.
I want to add inside the li tag a subtitle under the menu item name, the item that he get from wc_get_account_menu_items() function, but it doesn't have any subtitle in the $item.
How can i customize it in order to insert it in the navigation.php
I attach a file where it shows how it have to be rendered
I thought to insert an action at wc_get_account_menu_items in order to add teh subtitle but i can't figure out how :(
Thank you
Mirko
You can't get the HTML you required (as per screenshot) using woocommerce_account_menu_items() filter or any other filter.
So if you need the same structure, it is better to hard code the links & HTML in your theme by copying navigation.php from wp-content\plugins\woocommerce\templates\myaccount to wp-content\themes\your-theme\woocommerce\myaccount.
I've read through around 30 or 40 different articles today on how to achieve this and none give a really good simple answer.
Long story short, we have circa 40 categories and simply want to add a block of text with a link within it at the foot of every category page.
So looking to edit the category page template. We have our woocommerce folder setup in child theme and have other files overriding the default plugin. So we understand that it is probably the content-product.php file that is to be edited? But where and what code is applied? Tried adding in near the bottom but it gets caught up in the loop and adds it to the page for the number of products in that category as looped with product title, image etc.
Should we look at adding custom php in our child theme's functions.php file?
Any help greatly appreciated. Thanks.
There are a few different ways you can approach this but for the most part you're going to need to write some PHP.
To place something at the bottom of a category page you need to check how WooCommerce displays categories. Visiting the taxonomy-product_cat.php WC template will reveal that categories use archive-product.php. The next step would be to review that template file.
You want something to be shown at the bottom of the category page, it's only going to be displayed once so it doesn't belong inside the main products loop.
If you override the archive-product.php template and manually insert a link, it's going to appear not just on the categories but also the shop and tag pages. That tells you that you need a conditional to limit the display of the link.
Using the hooks WooCommerce provides means you won't have to override the template at all. There are 2 hooks in the file which may be suitable:
woocommerce_after_shop_loop - executed after the loop when there are products
woocommerce_after_main_content - executed at the bottom of the page whether or not there are products.
Write a function to output your link using one of those hooks:
function wpse_wc_category_footer_link() {
// woocommerce_after_main_content is a generic hook; check we're on a category page.
if ( ! is_product_category() ) {
return;
} ?>
<!-- Your markup for category pages belongs here... -->
My Link
<?php
}
add_action( 'woocommerce_after_main_content', 'wpse_wc_category_footer_link', 5 );
Situation: I have old site Agroteplica based on Joomla 2.5. I need to add custom html-code to menu items (for example, icons, or bold). I need unic icon for each menu item, so it's no use to edit php-template of page.
If I try to use html-code in menu item header - Joomla clear it, only text remains. I tried to find some manuals, and added line filter="raw" to file modules.xml:
<field name="title" type="text"
description="COM_MODULES_FIELD_TITLE_DESC"
label="JGLOBAL_TITLE"
maxlength="100"
required="true"
filter="raw"
size="35"
/>
But it didn't give any effect either.
Question: what I need to do to make it work? :)
Here is what Joomla provides for cases like this:
In Menu Manager -> Menu Item Edit
Editing each menu item, you will see the "Link Type Options" section at the right column.
See screenshot:
As you see in the screenshot, this group of settings contains the follow options:
Link Title Attribute : You can add your custom Title attr to the menu item's a tag.
Link CSS Style : You can add a custom css class for this menu item's a tag.
Link Image : You can add a custom image for this menu item.
Add Menu Title : If you add an image, you can choose to hide the Title of the link (setting = No), or choose to show both Image and the title (setting = yes (default)).
For you case, you can either choose you custom images-icons that should be displayed next to your menu items title. If you want bolds or other styling options, you can add your custom css rules to the items you want, and then add your css styles at your template's css.
For example you have decided that for some of your menu-items you would want their text in bold. Then you could do as follow:
1 .Give them a css class to all of them, in the Link CSS Style field: e.g. 'bold-items' (without the '').
2. Open your template's css file with a plain text editor and add the following rule at the end of the document:
.bold-items {
font-weight:bold;
}
Notice: The above settings might have no effect at all, if you are using a 3rd party menu module, or your template contains overrides for the default menu module. In such case you will need to add further template overrides for the menu module in use, in order to implement the above settings.
*Not sure what you mean with menu item header and how you did try to add html-code to it.
*Update / Answer to your comment:
You never mentioned about video in your question. You asked about adding icons and making text bold. What do you mean with headers and what kind of code and where are you trying to insert it? Are you aware of what is involved in the process from the moment you create menu items in the menu manager till you see those in the front-end of your website?
Following my answer above and assuming you have basic knowledge of the workflow (menu module, template overrides, css) you will be able to add images/icons or custom styles for each menu item. If you want to have video inside your menu, then you...
... will need a more sophisticated menu module. These are called Mega Menus and allow the user to display various types of content inside their menus, like modules, in various ways. You should either install a such module or create one on your own.
I would like to create a nav menu that displays all the pages of a wordpress site, its layout similar to what you would see in a footer sitemap layout, approx 5 columns with all the pages shown. Each page will be a project. I want to use wordpress category checkboxes (like you have for posts) to allow selection of one relevant category for each project page. Each page will then show a category caption below the project's description text, this I will style with CSS so each category has a different background colour.
Because Wordpress doesn't provide categories for pages, I have found a plugin to add this category feature to pages called ninja-page-categories-and-tags: http://wordpress.org/extend/plugins/ninja-page-categories-and-tags/
It's possible to edit the plugin php code under basic-functions.php to return a 'class' for the category displayed using get_slug and then applying css for each.
My problem is that on the menu, which will be a secondary menu in Thirty Ten displaying the pages, I want to be able to colour the background of each link to match the category that has previously been assigned to each page using the ninja plugin. Because the menu works with pages and the categories are not directly linked to the menu items (firebug will not show category details in the html of each link to reference with the css) I am wondering how I can colour each link based on category? Any ideas?
Ultimately what I would like to achieve is a grid of page links that are all coloured based on their category, a colour coded menu.
The plugin uses the standard wordpress category functionality but I just can't think how to connect these category details to the menu items to allow me to style them with css, any help would be really appreciated, even if just a point in the right direction.
Thanks
It's difficult to understand exactly what you're after, but essentially if you want to add extra classes to menu items (which will allow styling), you need to create a custom walker function.
Have a look at a tutorial like this: http://wp.tutsplus.com/tutorials/creative-coding/understanding-the-walker-class/