Programming custom PHP with Wordpress - php

I have a question regarding PHP and Wordpress.
I recently started using Wordpress for a simple website but there is still one thing that I just don't understand. Lets say I made a cool website in php that also cointains my header, my footer and my menu. How do I implement the Wordpress CMS so that someone else can add an item in the menubar that I made, instead of adding an item in a theme made by someone else? I have a hard time finding such tutorials because most of them are for people with no programming interests and because of that they don't explain such things.

If your only concern is how to connect your menu to the wordpress admin, you can check this link: wp_nav_menu()
that wordpress function will then generate a list of the menu items you add on the admin.
For example use this on your theme to display a menu from the admin with the name "Main Menu":
<div class="my-menu">
<?php wp_nav_menu(array('menu' => 'Main Menu' )); ?>
</div>

Related

Left Sidebar on Wordpress won't create menu

I tried googling this, but not having much luck...
I have been able to create a menu using wordpress and entering this code in my header:
<?php wp_nav_menu( array( 'theme_location' => 'header-menu' ) ); ?>
And this in my scripts part:
function register_custom_menu() {
register_nav_menu('header-menu',__( 'Header Menu' ));
}
add_action( 'init', 'register_custom_menu' );
But it seems that when trying to sort it, using the left side bar in the customize theme mode, it will not sort the menu nor will it remove any part of the menu that I add or remove using it.
From what I can tell it's just pulling my pages that I created within wordpress.
Keep in mind, this is a new theme I'm creating - my first theme. I have no PHP experience. Trying to learn as I go.
Picture of issue
I removed some of the names of the links for public view. I need to figure out how to also style this properly, but I've seen some other posts about it, so I'll review those later.
If someone can help me get this side menu to work with my current menu that would be great!
If you try altering your wp_nav_menu call to the following (no parameters):
<?php wp_nav_menu(); ?>
It should fall back on the first non-empty menu. While you may want additional menus later/will likely want to customize your menu(s) more, this should help with troubleshooting as whatever initial menu you have created (is non-empty) is the menu being edited by the customize page.
From what I can tell it's just pulling my pages that I created within
wordpress.
This likely relates to the setting "Automatically add new top-level pages to this menu" in the menu settings tab. This may be found under Appearance >> Menus, or under Customize >> Menus >> Clicking on the arrow to the right of your primary menu >> menu options (at the bottom of the resulting tab on the left).
Have you tried building the menu through Appearance-->Menu?
In the Wordpress backend, go to "Design > Menus", create a new menu there, add all entries you want to have, give it a name and in the "positions" tab on that page, assign it to the defined position in your theme (header-menu in your case). And disable the option to add all new pages/posts automatically.

Custom theme conflicts with menu

I am trying to add a drop down menu on my Wordpress website. I have a custom theme made by somebody I can no longer get in contact with. When I make a Page a sub-unit in the Menu section of the Wordpress admin area, it doesn't make that page a drop down. Instead, it just makes that page appear under what is supposed to be the parent. Any help is much appreciated. Here is the code for my menu:
<div class="navigation">
<?php
wp_nav_menu(array( 'menu'=>'main-menu','items_wrap'=>'<ul class="menu">%3$s</ul>'));
?>
</div>
The way your menu will behave will depend on how the theme and wordpress installed is configured. You will have to analyze the template and understand what it is doing and how it is rendering your menu.
Most of the times, the menu is hardcoded in the "index.php" page that is in the folder: "wp-content\themes\themename\"
Check there how the menu is build.

Order Pages in Wordpress

I am new to CMS development, I prefer the MVC concept for every job. But just know the client requested to develop a website built in WordPress. Everything is OK but I can't find to order pages in WordPress.
The case is: first I create a home page and then I create other pages, but the problem is every time I add new pages, it will be placed in my first menu.
So I want to move the home pages in first menu.
Please help, thanks.
You can create a custom menu (with the pages/links you want, and the order you want !). Then you can add that menu to be the new navigation menu (both header, and footer if you want)
References:
WordPress Menu (here you can find the step by step 'guide')
Just go to Appearance --> Menus and then you'll be able to create menus and edit at will. And if you need to create specific menus, see WP nav menu page. There you'll see several code samples, but you'll need something as simple as
<?php wp_nav_menu( array('menu' => 'Main Nav' )); ?>

How to apply front page(customized) design to the entire RESPONSIVE template

I’ve installed responsive theme and responsive master child also.
I’ve designed a custom front page design and I want the same design on the entire website.
Here is the website:
http://fulnet.org/
and here is the website pages.
http://fulnet.org/what-we-do/
Basicly I want to modify the header menu area and the footer.
I dont want the sliders and the rest only the menu and the footer area.
PLease help me I’m new in working with wordpress and I’ve spent the last two weeks trying to made this changes, but not succeeded.
Thank you for your time and for help,
Ionut
If you want the header and footer to be accessible on all the pages, just include the wp_header & wp_footer on your pages files.
On the one hand, you have a static html page: http://fulnet.org/.
On the other, you have a Wordpress Theme: http://fulnet.org/what-we-do/
What you need to do is to make the neccessary changes in your style.css inside your Wordpress Theme - wp-content/themes/responsive.

Joomla slider and contact us page

i have made joomla template 2.5 but not finished so far.
1) I have a home page with slider i have made extra file for slider slider.php and include it in template.
now slider should be in only home page how it will be possible?
2) I have some other pages like about us, contact, product and categories.
how it will be possible with template to make a contact form and send it to client email id?
I have some more problems will describe but first want to sort out them and then proceed please help .
I think you are a little confused as to what Joomla is. It's a content management system, thus runs on extensions. It's not like creating your own basic PHP based site and hard coding everything.
Don't hard code the slider into the template. Instead, create a module position where the slide is at the moment, then turn the slider into a module. Converting you widgets and so on when you already have the code is fairly simple.
As for the contact form, this is also an extension which is already built into Joomla. So, in the Joomla backend, on the top menu, go to:
Components/Contacts/Contacts
Create a new one and enter the necessary details.
Then, create a new menu item and set the "type" to "Single Contact". Or you could download a contact extensions from JED. If you want to e-mail the members of the site, go to the Joomla backend, on the top menu go to:
Users/Mass Mail Users
Then simply go on from there.
for your slider problem, if you want to display your slider only in landing page or front page then you have to check the front page in your index.php file and then start your slider so that your slider only work for front page like this:
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault()) {
// Start display your slider
}
The about example will work in joomla2.5x version..
To know more check the joomla DOC
And for your second question you have two options, one is create a component for contact and then apply on your template or try to find some already made contact components from joomla extensions. OR modify the current com_contect component.

Categories