Wordpress Navigation Label in Browser tab - php

I am trying to edit my header.php to call the navigation label of a page as opposed to the page title. Here is the existing code...
<title><?php wp_title( '' ); ?></title>
What is the code for calling or echoing the navigation label of a menu item?
Thanks.

What you need is to access the wp_nav_menu_objects, by first rendering the menu to extract the label in order to use it on the page title.
You can see a working solution well explained on this links:
How to get current-menu-item title as variable?
first render the menu and then display it later

Related

Convert html to wordpress & provide link to menu inside panel

I have an HTML template which I am trying to convert into PHP for WordPress.
The homepage has been converted and is shown properly. Next, the menu in navbar is about, the page that needs to be converted in PHP.
I have just added get_header() at the top and get_footer() below. In between these two I have added the HTML content for my entire page.
Then I tried to provide the link for the menu that I created, but the content of about page is not visible.
Do I need to add any other line for that page apart from get_header and get_footer? Or is something wrong with the link?
Clearly I can't understand what your are trying to say. I think you want to create a page that will show your about menu content.
So in your theme directory create a page name page.php and use get_header(); in first and below get_footer and where you want to show page content write the_content();. like this
<?php
get_header(); ?>
<div><?php the_content(); ?></div>
<?php get_footer(); ?>
after that follow the url of # Sajid Anwar. because for dynamic data you have to create pages(home,about etc) from wordpress dashboard and in menu section add these pages as navigation menu to menu.

How to set slider only on Homepage in Drupal 7.31?

I set my slider only on Homepage with tag in Drupal 7.31 but it black div is taking same div space on other page but slider is not coming. Help me.
I'm using "Bartik" theme.
If you want to display specific content on your drupal homepage than add following code in your page.tpl.php file or you can do it using create Block region position.
<?php
if (drupal_is_front_page()) {
// your slider code goes here
}
?>
If your content is a block, go in the settings of your block and choose the option : display only on listed pages, in listed page add the value <front>

Contao: Frontend - Get theme section of another page - not the current page

I would need to reach a custom section by page id (or PageModel Object), but I don't find a way to get the FrontendTemplate. I would like to use it in a dropdown navigation to echo a custom section of the hovered (parent) page.
If somebody will search for, the answer is:
<?php
$articles = \ArticleModel::findPublishedByPidAndColumn($id, $column_name);
echo static::getArticle($articles[0]); // for ex. the first article
?>

wordpress link home page to different page

I have created html pages and trying to convert into wordpress theme,how to link html one page to other page in wordpress menu bar
sample code :
Features
this code is not working,it 's showing page not found.how to make this link in wordpress using php code.
Firstly Create Page "Features" from wp-admin.
Create template for this page.
http://codex.wordpress.org/Stepping_into_Templates
To set this page in menu Go in "Menu" section in WordPress.
http://codex.wordpress.org/Appearance_Menus_Screen
To view this menu in fronted use wp_nav_menu()
Take example template from your theme.
This is file in theme ending with -page.
Change template name in head of a file.
Then remember about the_loop all should be inside a loop to work correctly with many pages.
Put html there, also in header.php attach css to this html.
Page structure is like, header in the up, then page and then footer.
Remember to preserve good html structure - divs beginning and ending.
Then you create a page with content ( which is presented in the_loop ) , which has its own url address.
You can set url naming of pages in settings -> permalinks, you may need to write to .htaccess file.
Then you have direct url to page. You can use it in code like this:
echo bloginfo('url'). 'nameofpage';
All to do is create a template and assign it to page ( on page edit page template option ).
You can use pages or posts for this, i prefer pages.
Create new pages or posts and get their ID.
For linking its:
Get link with this:
get_permalink( $yourPostOrPageID ); // only get; not echo
Otherwise
Wordpress homepage link:
get_bloginfo('home');
Category or custom taxonomy term link:
get_term_link( $term, $taxonomy );

If category/page in wp_nav_menu exist

I need your help
I have three custom menu(wp_nav_menu) which I customize via admin menu section.
<!-- first menu ->
<?php companyMenu(); ?>
<!-- second menu ->
<?php servicesMenu(); ?>
<!-- third menu ->
<?php partnersMenu(); ?>
I want to show only one nav menu to which opened post/page/category belongs
For example: when I'm on home page click "Contacts" in menu it redirects me to "Contacts" page and because this page defined (with other menu links) in companyMenu() wp_nav_menu function it shows
It would really depend on how many pages you would need to check against for my solution to be viable- the fewer pages the better.
You could wrap your menu code in if statements and use the is_page wordpress function to check if you are on that page. See the link below for more information.
http://codex.wordpress.org/Function_Reference/is_page
Code Example
if(is_page( 'Contact' )){
servicesMenu();
}
As a general rule the wordpress codex has a great wealth of knowledge which I found really helpful when starting wordpress development

Categories