I am trying to convert my normal HTML website which consists of home, about, and T&C pages to WordPress, I have created the theme folder which Consists of index.php, functions.php, header.php, and footer.php files. So now my question is how can I add and link my other pages (about, T&C pages).
You have to use /* Template Name: Home */ on your custom page.
For more example:
see here
You need to register a menu see code below and link to Codex
function mytheme_register_nav_menu(){
register_nav_menus( array(
'primary_menu' => __( 'Primary Menu', 'text_domain' ),
'footer_menu' => __( 'Footer Menu', 'text_domain' ),
) );
}
add_action( 'after_setup_theme', 'mytheme_register_nav_menu', 0 );
https://developer.wordpress.org/reference/functions/register_nav_menus/
Related
I created a link to connect the viber in wordpress. But it does not working.
<a href="href='//chat?number=xxxxxxxxxx'"/>xxxxxxxxxx</a>
In your theme functions.php (preferable child theme) use this to allow "viber" protocol:
add_filter( 'kses_allowed_protocols', function ( $protocols ) {
$protocols[] = 'viber';
return $protocols;
} );
It contains
Home,
Company,
Help & Support,
Products,
Pricing, and
Sign In.
I use this in the navbar in the header and i will be using it on the footer. In footer it will only display all of the menu items excluding Sign in. What should i do? Im new to wordpress.
<?php
wp_nav_menu( array(
'menu' => 'primarynav',
'depth' => 2,
'container' => 'div',
'container_class' => 'collapse navbar-collapse',
'container_id' => 'bs-example-navbar-collapse-1',
'menu_class' => 'nav navbar-nav')
);
?>
Step 1: login to your cpanel root directory of WordPress then open wp-content -> themes -> your theme -> functions.php
Step 2: In functions.php file create secondary navigation something like this
register_nav_menus( array(
'secondary' => __('Secondary Navigation', 'twentyten')
) );
put your theme name instead of twentyten
Step :3 now open wp-content -> themes -> your theme -> footer.php
where you would like to call footer menu use this code
<?php
wp_nav_menu( array(
'menu' => 'Secondary Navigation',
'depth' => 2,
'container' => 'div',
'container_class' => 'collapse navbar-collapse',
'container_id' => 'bs-example-navbar-collapse-1',
'menu_class' => 'nav navbar-nav')
);
?>
Step:4 log in to your admin end and appearance -> menus -> create new menu -> add the menus exclude sign in and tick the box Secondary Navigation
Thats it
Answer given by Minal Chauhan is correct. That is the one way by which you can do the things that you want.
Another way is keeping the same menu in admin, you just need to add class to "sign in" menu.
Here is the screenshot to describe how you can give class to particular menu item
If you are not able to view CSS Classes field, you have to enable it from screen option which is located in top right corner.
Here is the screenshot how to enable Class option for menu items:
Now, after giving class you need to write following jQuery code:
jQuery(document).ready(function() {
jQuery('footer .test').closest('li').remove(); // here .test is the class which I gave to my menu item. And Footer is parent div element from where I want to apply this jQuery code. // these selectors you may need to change as per your HTML code.
});
Please let me know if you need any further help.
Thanks!
The following is the code from WooCommerce to Add Extra Tabs:
My Question is, how to insert a video link, or an iframe in the tab content.
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
// Adds the new tab
$tabs['test_tab'] = array(
'title' => __( 'New Product Tab', 'woocommerce' ),
'priority' => 50,
'callback' => 'woo_new_product_tab_content'
);
return $tabs;
}
function woo_new_product_tab_content() {
// The new tab content
echo '<h2>New Product Tab</h2>';
echo '<p>Here\'s your tab content.</p>';
}
How to insert anchor text, or iframe inside "Tab Content"
Any Help would appreciated..
Cheers
If you just want to show a static video iframe in your tab content, then simply add iframe/video tag in your tab content callback function likes
function woo_new_product_tab_content() {
// The new tab content
echo '<h2>See the video</h2>';
echo '<div><iframe width="100%" height="315" src="paste your video link here" frameborder="0" allowfullscreen></iframe></div>'; }
Or if your wants dynamic video link for each product then you must have to store video link in respective product meta first. And then echo get_post_meta for video on above 'src' attr.
I'm just wondering if there's a way to add a class to any navigation lists for things like sub-pages, categories, archives, meta?
I can't find anywhere in my templates to add a class as I guess it's all autogenerated?
My parent theme (html5blank) has a section of code (below) where this is referenced but I think it targets all lists in the sidebar...
if (function_exists('register_sidebar'))
{
// Define Sidebar Widget Area 1
register_sidebar(array(
'name' => __('Widget Area 1', 'html5blank'),
'description' => __('Description for this widget-area...', 'html5blank'),
'id' => 'widget-area-1',
'before_widget' => '<div id="%1$s" class="%2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>'
));
// Define Sidebar Widget Area 2
register_sidebar(array(
'name' => __('Widget Area 2', 'html5blank'),
'description' => __('Description for this widget-area...', 'html5blank'),
'id' => 'widget-area-2',
'before_widget' => '<div id="%1$s" class="%2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>'
));
}
I realised I can add a class to a parent div by amending the before_widget line to read something like:
'before_widget' => '<div id="%1$s" class="%2$s CUSTOM-CLASS-HERE">',
That does add a class but I still thing it'll be added to any and every widget that's added to the sidebar?
Presumably that will mean any widget that contains a ul will inherit styles applied to that class, which will break the widget's appearance?
Hope someone can help with this :)
You can add classes to menu items (or to menus) from WP Dashboard.
Appearance > Menus > Screen Options
Show Advanced > CSS Classes
Click any menu item to expand and add classes.
In CSS, you can always prefix those the classes with a specific id or class of a widget area, to only apply styles in specific sidebars/widget areas.
if you need to add a class to all your menu items programatically, use the
nav_menu_link_attributes hook:
function add_your_menu_classes( $atts, $item, $args ) {
if( /* condition based on $args or $item (WP_Post object)
* (in case you only want this when a particular condition
* is met). If not, just remove the condition */ ) {
$atts['class'] = 'some-class';
}
return $atts;
}
add_filter( 'nav_menu_link_attributes', 'add_your_menu_classes', 10, 3 );
I think if ur widgets, displays a kind of navigation you have to use a custom NavWalker to modify link classes
https://github.com/wp-bootstrap/wp-bootstrap-navwalker
i'm trying to render meta tag on page header by use:
In my View:
<?php
$this->registerMetaTag(['name' => 'keywords', 'content' => 'yii, framework, php']);
?>
and in my layout i put this code in head tag position:
<?php $this->head()?>
But it does not working. Anyone who have the same problem, can help me solve this problem. Thank you !!
To define a meta tag through the registerMetaTag method, use the following code in your controller:
public function actionIndex()
{
\Yii::$app->view->registerMetaTag([
'name' => 'description',
'content' => 'Description of the page...'
]);
return $this->render('index');
}
and this markup in the layout:
<head>
<?php $this->head() ?>
</head>
I've updated the basic demo application (from http://www.yiiframework.com/download/) that you can download here - https://www.dropbox.com/s/9rarzhtw65e5zo1/basic.zip?dl=0 and see this approach in action.