I have created a menu like so... http://tinyurl.com/p5xr852
You can see I have added links under "What's Happening?" which I want to use as page anchors from a sidebar.
What I need to do is have these items list in a sidebar when on the parent page.
I have done a heap of research and found that wp_get_links is now deprecated (see here http://codex.wordpress.org/Function_Reference/get_links)
Apparently this has now been replaced with wp_list_bookmarks()
Is there any way what so ever to do this? I don't want to go down the route of creating a heap of multiple menu's as I will be adding these links under post pages to act as page anchors.
I hope I understood correctly. You want that list of links displaying on the sidebar, when the user is in "What's Happening" -page OR any of it's child-pages?
If I didin't understand then just skip this but.
Create a new text widget that has your pages as a list like this:
<ul>
<li>Overview</li>
<li>Schedule</li>
<li>etc</li>
<li>etc</li>
<li>etc</li>
<li>etc</li>
</ul>
Then get the Widget Logic plugin: http://wordpress.org/plugins/widget-logic/
This plugin allows you to choose where widgets appear, for example in certain pages, in archives, in certain languages, in child-pages etc.
Check out: http://wordpress.org/plugins/widget-logic/other_notes/ on how to make this link-list-navigation-widget to appear on the pages you want it to.
It's something like
global $post; return (is_page('15') || ($post->post_parent=="15"));
You put the ID of the page on which you want the widget to appear on. And its child-pages with the latter.
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 have a WordPress for my science journalism blog and I would like to add a page that contains a subset of the blog posts. For example, having a page populated by a certain category (i.e. review articles) or tags (i.e. physics).
There seems to be a way to do this by making a new php page, but I am not sure how to get to a blank template to add the code base.
Alternatively, I would prefer having a way to do this without having to mess with the code at all. Any help would be much appreciated. Thanks!
This happens automatically with WordPress; read the docs:
When a viewer clicks on a link to one of the Categories on your site,
he or she is taken to a page listing the Posts in that particular
Category in chronological order, from newest Posts at the top to
oldest at the bottom.
Read https://codex.wordpress.org/Category_Templates
You don't have to make a category or tag template page, but you can if you want to. This is theme-dependent; your theme may already have different archive page templates.
The URL for a category or tag archive page will be:
example.net/category_base/category_name
example.net/tag_base/tag_name
Read https://codex.wordpress.org/Using_Permalinks#Category_base_and_Tag_base
Go to Appearance>Settings>Reading to set number of posts per page and either excerpt or full post.
I think you should be able to get at a category by going to http://example.com/category/mycategory
And to tags by visiting http://example.com/tag/mytag
You should be able to add categories to the main menu, and add tag pages via a custom link OR use a tag cloud?
Hope this helps.
I've been struggling with this for a couple of days now and can't think anymore.
I've created a template for a particular page for event menus and within that page I have a sub menu. This sub menu has event menus. For the purposes of example: Item 1, Item 2 and Item 3
These menu items are their own pages.
The submenu should open the pages in this template. Page layout example below:
Header
Main Nav
Banner Image
Content for Events
Event Menus (Item 1 | Item 2 | Item 3)
Menu Content
Footer
Menu Content switches out by clicking on the menu items, but the Content for Events stays static.
I currently have it working by adding a $_GET variable to the end of the links, but I've hard coded the menu. I don't want this because then the client can't make their own menu changes and edit their menus. (The amount of changes so far has been ridiculous.)
I've put the Event Menus and Menu Content into another nested loop, theoretically so it reacts inside the loop, though initial tests with this have failed.
I'd really like to keep the dynamic nature of Wordpress' menu system, but can't get this to work without hard coding.
At this point I'd be happy with direction on where to research.
Thanks.
If your HTML for the menu content is not too unwieldy, you could potentially drop each menu into a Wordpress Page, where the client could edit it. Simply create a Wordpress page for each menu, drop in your menu content, save it, and make a note of the Page's ID number.
Then, in your template, you can pull in the menu content by getting the Page with something like this:
<?php
// Menu One is content in Page ID # 14
$menu_one = get_post(14);
echo apply_filters('the_content', $menu_one->post_content);
?>
For your reference, get_post on Wordpress Codex: http://codex.wordpress.org/Function_Reference/get_post
On your actual page, what you could do instead of using a GET to grab each menu, is just go ahead and load all 3 menus on page load. Using CSS, you can hide the two you don't want at first and just show the default one. Then using some JavaScript events on the menu item links, you can show the clicked-on menu and hide the other two.
I've put a few notches in my oop and WP programming since asking this question. I think the better way to do this is a custom post type and change the wp_query object with parameters based on the link which can probably just be controlled by post ID. But it would still allow for a menu to be added to the "archive" page that controls the posts. Ultimately allowing client control of the menu, but still having a dynamic ability.
I have a Wordpress site comprised mostly of pages, but there is one page (news section) that contains posts and categories like a blog would. I'm generating my nav using wp_nav_menu() with only the top-level pages displayed. I have styles set for the current link and the current link's parent that use the .current-menu-item and .current-page-ancestor classes that wp_nav_menu() automatically adds.
However, when you're viewing a post within the news section, no classes are added to the nav to indicate that you're in that section, and there's no way to style the "news" link to show that it's the section of the site the user is in.
Is there a way for WP to "know" that posts belong to that page? It's not a category because since no other sections of the site contain posts, the categories field is open and the editors can add whatever categories they want.
Do you have your "News" page set as your blog page, in the "Reading" settings? If so, it should add the class "current-menu-parent" and "current-post-parent" to the "News" <li> when you are viewing a post.
According to Wordpress template hierarchy (and specifically this diagram) a single post is being displayed by a file called single.php (or single-<post_type>.php. A set of posts from a category will be displayed by category-<post_type>.php template file.
Now, if you abide to this hierarchy, you'll have two more templates - news list and news detail page. Having two pages with these templates will make them automatically listed by Wordpress menu-generating function.
If that's not enough for you, you should use WP_Query to manually list your pages. If you decide to do it this way, one or two if statements should do the job.
I am currently teaching myself WordPress and working on my own CMS site.
My site will consist of approximately five pages where the header/sidebar menu/footer will be seen on all these five pages.
Beginner here and questions are as follows:
All these five pages will consist of different content, for example, every page will have a image banner representing the menu option just clicked, for example, "About Us" on page 5, "Promotions" on page 4 etc and then some text beneath that and then possibly some images inside a carousel set up.
Within WordPress, how would I tackle this, i.e. do I just create a page in WordPress, position the banner image at the top of the page, then have a few breaks and then insert the carousel of images - is this correct?
If not, do I need to create a separate php file called aboutUs.php that has this markup and then somehow link it to a WordPress page?
On my landing page of my site ONLY (page 1), just above the footer, I want to display a div section that displays all the sponsors of the website along with a URL to click to their websites - how would I go about doing this in WordPress?
Furthermore, with my menu, how do I link my menus to point to the WordPress pages relating to that menu option?
If you use the 'default' template that comes with WordPress you could do something like this to generate different content on different pages without creating separate php files (this would go in page.php):
<?php if(is_page('About Us')) { ?>
<?php $about_query = new WP_Query('category_name=aboutus-&showposts=1');
while ($about_query->have_posts()) : $about_query->the_post(); ?>
<?php the_content();?>
<?php endwhile;?>
Essentially, in this you could just create a post and an 'aboutus' category to reference it. The page of 'About Us' (referenced through is_page()) would contain the content you wanted to display.
First, some background. Wordpress has a number of ways to display stuff, such as images, text, and query results; here's a list:
THEMES
You can modify your theme files directly to do whatever you like. This will probably involve learning a lot about PHP and the Wordpress internals, but there are plenty of books, and the Wordpress Codex to help you. You can get themes from the Wordpress theme directory.
PLUGINS
There are huge numbers of Wordpress plugins, any one of which might fit your need. Plugins will require configuration, but generally won't involve learning PHP -- just how to install and configure them. Most of the SEO (Search Engine Optimization) plugins will allow you to place custom HTML in the templates (nominally for ad placement, but you can do anything you want with it). You can get plugins from the Wordpress plugin directory.
WIDGETS
The base Wordpress software and many plugins provide Widgets. A widget is a display element that can be docked in one or more widget areas. Typically a widget will be a chunk of HTML (often an unordered list) that has the theme's style sheet applied. Widgets are often used for ad placement, navigation elements (menus, dropdowns, breadcrumbs) or to provide tag clouds, category lists, calendars, etc.
SHORTCODE
A shortcode is a macro that can be placed in a page or post, that will return a chunk of HTML. Shortcodes can take parameters that will affect what the shortcode returns. The base Wordpress software provides some shortcodes, but many plugins will provide shortcodes as a way to get more functionality without the need for widgets or theme modifications.
With all of that in mind, here's my answer(s) to your question(s):
Modify your theme to include a page template, and add your image selection code to the template. Then create your individual pages, and then select your template while editing the page.
The 'landing page' can be any page (instead of the default blog index page); create a 'home' page and a 'home' page template that includes your advertisements. Alternately, use a SEO plugin to add the ads above the footer.
I don't know what theme or plugins you use, but generally you can configure a navigation menu to work from a list of pages, specifying either which pages to include or which pages to exclude. If your theme doesn't include this functionality, I'd recommend choosing a different theme.
Look into Wordpress "page templates". The Wordpress codex can help you understand this.
If you edit a post in WP you will notice the option to use a template. That is your goal. Learn how to work with them.
Wordpress themes are composed of multiple files. One of them is the header.php file which contains the header content. The footer.php file contains the footer and the sidebar.php contains the sidebar. These are the usual conventions. They're not strict. There will be a couple of main files which include these (e.g., index.php - Used for articles, page.php - Used to display pages etc.)
If I were making a setup like yours, I'd make five "pages" (using the backend) and then customise my page.php file to present it properly. I'd still keep the header, footer and sidebar separate from the page.php file since they'd be there for pages like 404s etc. as well.
Just put something in the content of the landing page to display this.
IF you're doing theme development, the right place to look at is http://codex.wordpress.org/Theme_Development