wordpress multiple pages on one page - php

i am developing a CMS site in wordpress ...
the final web page should some what look like :
Website
I want just one page (front page) and on that i want to display subpages titles in it. (About,Home,People)...
So when the subpage title is clicked it should expand and display the the page content in the panel,on same page and at same place.
any ideas regarding same?
Thanks in advance...:)
EDIT1
[accordions]
[accordion title="Accordion 1"]
Accordion 1 Content here
[/accordion]
[accordion title="Accordion 2"]
Accordion 2 Content here
[/accordion]
[accordion title="Accordion 3" last="last"]
Accordion 3 Content here
[/accordion]
[/accordions]
after puting the above code in the page content looks like this:
but on click of ACCORDION 1 its not getting expanded..

You can write your own template, which does a query (checks for a subpage), and adds its content between div tags.
When it's done, then it's time for JS/jQuery . Search for tab jQuery scripts, so you get some information.
Anyway, you will mostly need to use hide() / show() functions to reach something like that.
Also, did you made that template, and are you familiar with programming in WP?
<?php
$args = array(
'numberposts' => -1,
'post_parent' => $post->ID,
'post_type' => 'page',
'post_status' => 'publish',
'orderby' => 'menu_order,title',
'order' => 'ASC'
);
$my_pagelist = get_children($args);
?>
Above is code for displaying subpage content, below is the jQuery tutorial for tabs.
http://jqueryui.com/demos/tabs/
EDIT:
Also, check this site - http://www.learningjquery.com/2006/09/slicker-show-and-hide it will show you some info about show/hide functions. Also more information about WP get_children function is found here - http://codex.wordpress.org/Function_Reference/get_children

If I understand your question correctly, in the latest version of WordPress.
Login to your admin panel.
Click on the 'Settings' tab, then the 'Reading' sub-tab.
Change the 'Front page displays' option to 'A static page'.

Related

Wordpress sidebar custom icon

I'm in the process of setting up a sidebar on my wordpress site, the sidebar lists all pages within the current section using the code below:
<?php
wp_list_pages( array(
'title_li' => '',
'child_of' => wp_get_post_parent_id(),
'link_before' => '+',
) );
?>
The + icon in the link_before field adds the icon before the page name is output. Ideally what I'm wanting to do is output the pages icon attribute in here, although I can't seem to work out a way to do this.
The page has an icon saved as a custom field, which can be easily output on the page itself using the code below.
echo get_post_meta($post->ID, 'Icon', true);
if anyone's aware of a method which would make this achievable, please let me know.
Thanks

How to create specific footers for specific pages in wordpress?

So - I've been running around ways to do this and get half way there which is a bit infuriating!
Using jetpack portfolio - I want to show normal categories in my blog section and posts, and jetpack project types on the portfolio page and single projects.
My current code looks like this - and shows the jetpack portfolio types for the first post on the archive-jetpack-portfolio, and display correctly on the single project. but doesn;t work at all for the blog posts.
<?php
if (is_page_template('page-blog.php','single.php','index.php' )){
wp_list_categories(array(
'show_option_all' => '',
'title_li' => '',
'separator' => '%20',
'orderby' => 'name'
));
} else {
the_terms($posts->ID, 'jetpack-portfolio-type');
}
?>
So if these pages - show this, else show this. I know the $post-ID is where it's falling over for the archive page. Don't know why the blog bit isn't working.
Hope that's enough to go on. I bow to your infinite knowledge hive-mind!
Depending on custom template you have created you will need to call for custom footer using get_footer function. Here you can read more about get_footer function. You just need to specify $name parameter.
Monika

Custom Post Type Inside Regular Post Type

I am working on a website in Wordpress where I need to use custom posts (which I already created with the help of a plugin).
The problem is that the theme that I use allows me to display the post on the page organized according to categories, but when I create a custom post and put it into a category it is not displayed on the web (as if I had never created the post) but if I create the same post from the normal page of Wordpress entries (a standard Wordpress post type) and I put it in the same category this is shown on the page. Also, when I enter the custom post page the entry I created appears but when I enter the normal entries page it does not appear.
I went to a portal where they said how to add the custom post to the Wordpress categories by writing some lines of code in the functions.php file but this did not work, now I see the custom post within the category page but I still do not see them inside of the Wordpress entries page and also still not shown on the web.
You need to create a custom query. This page has good explanations and examples: https://codex.wordpress.org/Class_Reference/WP_Query
The most important thing in your case is to include this in your arguments array, which selects posts and your CPT:
'post_type' => array('post', 'your-custom-posttype'),
and also this which filters by category:
'category_name' => 'your_category_name'
So a typical simple custom query would look like this:
$args = array(
'post_type' => array('post', 'your-custom-posttype'),
'category_name' => 'your_category_name',
'post_status' => 'publish',
'posts_per_page' => 12
);
$query1 = new WP_Query( $args );
if ( $query1->have_posts() ) {
while ( $query1->have_posts() ) {
$query1->the_post();
echo '<li>' . get_the_title() . '</li>';
// Other stuff echoing content etc. to be added here.....
}
wp_reset_postdata();
}

Can I display a custom template page linked to a child page on a parent page - Wordpress

I'm creating a Wordpress template from scratch for my company's website.
I don't know much about PHP but I know my old company has succeded in doing the operation I want to do but I don't find any solution on the Internet...
I would like to display in a parent page, several child page and the template page that they are linked to. That way, I could display the template page as a block that can be re-used in several other pages.
For example I created a template named home.php that will be the parent page, and a custom template introduction.php with one of my block structure. In wordpress I have created a parent page for my homepage, and a child page with my template introduction.php linked.
I would like to display in my parent page, the child page and the template content to have the structure + the content of the child page.
In each parent page, I'll have several child that can have the same custom template.
I find this solution better than creating a full static page and giving it the ID of the pages or putting my HTML directly in a page editor, but I don't know if this solution exists.
For now I have only find solutions to loop child page into the custom template and then display the template with "get_template_part" into the home.php, but it displays all my templates even if they aren't link with a child page and shows the content twice...
Thank you if you can help me with this problem and sorry for my broken English.
So you want a 'parent page' that displays all the 'child page contents' in the 'parent page' itself like blocks
add this in your parent template file,
`<parent page content here>
<?php
$args = array(
'post_parent' => $post->ID,
'post_type' => 'page',
'orderby' => 'menu_order',
'order' => 'DESC'
);
$query = new WP_Query($args);
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post();
$template = get_post_meta( $post->ID, '_wp_page_template', true );
$template = pathinfo($template);
$template_parts = explode('-', $template['filename']);
get_template_part( $template_parts[0], $template_parts[1] );
endwhile;
endif;
?>`
This should get the child pages to the parent page, here i will be using the template file like this 'template-introduction.php' and i will be adding the 'introduction' as the template name.
This is assuming you have different templates for the child pages.
I have't tested this, in theory this should get you what you need.

Create custom menu in php based on pagenames

im trying to make a custom hardcoded menu in a wordpress page-template. The site has 3 pages (1, 2, 3) and at page 1 i wish to loop trough all pages that has page1 as pagetemplate and 2 for 2 etc.
How can i loop trough and get the names of all pages so i can put them in a menu?
if for example you visit page 1 and the pages that has page1 as template (parent) are "visit us" and "read more" the menu would look like this:
-visit us
-read more
but if i go to page 2 the menu might look like this:
-funpark
-foobar
Now if I add a new page with "1" as parent and name the page "about" the new menu will now show
-visit us
-read more
-about
Cheers,
Emil
You can query for pages and their template value. The codex says:
The filename of a Page's assigned custom template is stored as the value of a Custom Field named '_wp_page_template' (in the wp_postmeta database table). (Custom fields starting with an underscore do not display in the Edit screen's Custom Fields module.)
This means you can build a page query like this:
$args = array(
'post_type' => 'page',
'meta_query' => array(
array(
'key' => '_wp_page_template',
'value' => '[Your template goes here]'
)
)
);
All you have to do is loop through the pages, get the permalink and build your menu.

Categories