In one theme (FloZo) I've seen a nice functionality and I would like to learn how to make something similar. It's about a portfolio page, take a look at the demo "Our Work section".
You create a page and give it a template (Work archive) via Pages menu - more or less understood
You don't add any pictures there!
In your Dashboard you have a nice "work" section, where you can choose "make a new work item" - you add pictures with titles and descriptions there. - This is the big trick!
Now: my newbie idea on how it works:
The template is just the "body" of the page with the title
The dashboard "work" section must be doing something like this:
When you post a work item, it pastes/appends the whole item code into your page (like an item template code) with your specific image and text. It also creates an item-specific page (it's where you end up after clicking on an item).
My question is: is there any slightest possibility to add such a functionality to a Wordpress theme?
Here is how I see it:
The page template, 'Work Archive' has the loop that is displaying posts of 'Work' post type.
So to achieve this first you have to add the custom post type of your liking, and then in the page template add a custom loop to display these:
<?php
$args = array(
'post_type' => 'your_post_type',
'posts_per_page' => -1 //or whatever you choose
);
$work_query = new WP_Query($args);
if ($work_query->have_posts()) : while ($work_query->have_posts()) : $work_query -> the_post(); ?>
<!-- loop content goes here -->
<?php
endwhile;
endif;
wp_reset_postdata(); // always reset post data after custom loops
?>
If you need more info pleae don't hesitate to ask.
Happy coding!
Related
I have been searching on google but unable to find any proper tutorial. Can anyone tell me how do i make my own post page in wordpress?
For Example:
In wp-admin, There is already a Post option in menu..
Post>Add New
Post>All
Post>Categories
Post>Tags
In Add New, There is a blog form, where we can add post but I want another option in Menu.. called Licenses, Then option of Add New, When i click on it, There will be a form, What I have to do is to add Featured image in it and add title of it and publish and then it should show on license page. Demo License
Similarly I want another Trades, in which I should add trades and it should show on trades pages. Note, the trade page and license page will have different Style for showing, different Css. In Trade page there will be a boostrap accordion which will show trades, Demo Trades
Similarly I want another page for this affiliation page.. Demo Aff IN this page, there are some images with title, and sometimes client send more images, so i want a form in my wp-admin where i can just upload image and show on page like im showing. It will show differently for all pages.
How will i achieve this? Any suggestions? Any other method? im totally new to wordpress
You can create your own page template. Here is the reference
In your template directory create a new file like page-anyhing.php
Add this to your start of the file:
<?php
/**
* Template Name: Anything
*
* #package WordPress
*/
Then, when you create a new post, at the right side of the dashboard, you can select the Anything from Page Template menu.
You need to build your page template by PHP and HTML codes.
UPDATE
Based on OP comment:
You need to create a new template, eg. affiliates as I mentioned above.
When you get a new affiliate, then you can create a post, and add Category: Affiliates.
In your page template you need to get posts by categories:
$query = new WP_Query( array( 'category_name' => 'affiliates' ) );
Here is the reference from WP_Query.
if ($query->have_posts()) {
echo '<ul>';
while ($query->have_posts()) {
$query->the_post();
echo '<li><h2>' . get_the_title() . '</h2><div>Show image here</div></li>';
}
echo '</ul>';
} else {
echo "Sorry, no affiliates...";
}
/* Restore original Post Data */
wp_reset_postdata();
I would like to direct users to appropriate archive pages from within the menu. If I want this I need a page that I can attach to the menu.
How would I display the exact same stuff as on the archive page (archive.php) on another page so that pagination and functionalities remain the same, but some stuff will be taken from the actual page ? (can create custom page template of course)
I'll still have to show a sidebar for the page that you visited and not archive's sidebar
Breadcrumbs path will still have to show current menu item position and not archive page path
To show sidebar from the actual page is of most importance here.
EDIT
What I want to achieve is this actually:
Lets say I have a page
http://my.page/subpage/something/notifications/
I want that on this page, I can display exactly the same stuff as on the certain archive page which is here:
http://my.page/subpage/notification/
('notification' is a custom post type here)
I already have a solution that displays all archive stuff on another page (created a page template for that), but its a bit complicated to display title, breadcrumbs and sidebar properly for each page, since some of these should stay the same as they would be, but some should take the value of another site.
You can create a custom page template and assign it to a page. On that page you can use get_posts() to query the posts you want, like this:
global $post;
$posts = query_posts( /* Your args here*/ );
foreach($posts as $post) {
setup_postdata($post);
// Do your stuff as in archive.php
}
wp_reset_postdata();
Where can I find a soucre that learn to create a Responsive One Page WordPress Theme so when I click on the menu item it scroll down.
Here is an example of what I want http://thememints.com/templates/?theme=Cingle%20WP.
I have had exactly the same question and after searching around found this post.
I was rather shocked to see the responses to this question. It seem to me like people are quick to answer questions without properly reading the question.
All the contributors have given solutions to responsive and parallax scrolling websites but not one has answered the real question.
It is not too broad, and it is not vague. All he is asking is how you go about creating a Single page theme in WORDPRESS.... no one gave any direction as to how to accomplish this.
Not sure why these answers got rated as usefull .
So after digging around with trial and error I found the following to answer the question as to how you go about to create a single page WORDPRESS theme.
One of the major aspect to understand is the Wordpress query-post function which allows you to post multiple page content such as home , about, service and content onto a single page.
To create the the menu structure to scroll to the different sections I found this tutorial to be usefull - create-a-single-page-wordpress-website
I hope this helps
As William Patton said this is a broad question but as far I can understand this may help :
http://www.designerledger.com/parallax-scrolling-tutorials/ for the one page theme.
and a basic start for wordpress development theme :
http://codex.wordpress.org/Theme_Development
Update : I found this awesome plugin that helps you create full screen pages
https://github.com/alvarotrigo/fullPage.js
EDIT 2016
Due to the many up votes at user3263807 answer I made a small/basic one page guide for wordpress. For css/js there are plenty good tutorials and plugins over the internet. Also I assume you are familiar with WordPress Themes.
First of all you should create a template file for your one page. Let's call it template-one-page.php. The template name, commented inside the file, is the name that will appear in Page Attributes -> Template when you creating a page inside admin panel. After that create a page, ie Home, and assign as template your template. If you want your page to appear as front page (when you enter mydomain.com this page will be shown) go to Setting->Reading->Front page displays->A static page and set as front page your page.
// File Security Check
defined('ABSPATH') OR exit;
/*
Template Name: One Page
*/
?>
Normally a one page has sections. So we want to decide what type of sections we want. It could be pages, child pages, posts, custom fields (like a repeater from ACF) etc.
<?php
$id = get_the_ID(); // The page id
$sections = get_posts(array('post_type' => 'page', 'post_parent' => $id)); // get all child pages
foreach ($sections as $key => $section):
?>
<section id="page-<?php $section->ID; ?>" <?php post_class('', $section->ID); ?>>
<h1><?php echo get_the_title($section->ID); ?></h1>
</section>
<?php endforeach; ?>
Or with a Loop
<?php
$id = get_the_ID(); // The page id
$query = new WP_Query( array('post_type' => 'page', 'post_parent' => $id) ); // get all child pages
if($query->have_posts()):
while ( $query->have_posts() ) : $query->the_post();
?>
<section id="page-<?php the_ID() ?>" <?php post_class(); ?>>
<h1><?php the_title(); ?></h1>
</section>
<?php endwhile; wp_reset_postdata(); ?>
<?php endif; ?>
You can query what ever you want depending the need of your site.
you should take look at below link:
[1] http://www.1stwebdesigner.com/css/responsive-website-tutorial/
[2] http://www.1stwebdesigner.com/css/create-a-responsive-website-video-tutorial/
[3] http://readwrite.com/2013/04/16/10-developer-tips-to-build-a-responsive-website-infographic#awesm=~okrhufNGLHp1mh (Best one to keep points in mind while creating )
Thanks.
Here is full detailed video tutorial that deals with setting a one-page scrolling Wordpress website from any theme you want. Need to join - there is a free trial. This allows you to "peek under the hood" and understand the principle of how the other one page themes and plugins were created.
http://www.lynda.com/WordPress-tutorials/WordPress-Building-One-Page-Style-Site/169876-2.html
I have looked into several ready-made themes, such as Onesie and OneEngine, and found them a nightmare to manage on the back end, very user unfriendly. The content of the long home page with several sections in both themes is managed not through the Pages section, like one would assume, but through a different admin section in the Appearance folder, with none of the usual Wordpress interface controls. The tutorial above deals with it properly, with the real Wordpress Pages assembled by a custom loop on the front page and menus working in the same way as built-in Wordpress menus.
I used localscroll and scrollTo jquery plugin in my one page theme, it's working fine.
The plugins link:http://flesler.blogspot.com
After you imported the jquery and plugins files into your page, just call the function like below, then if you click a anchor link, the page will scroll up or down smoothly.
$.localScroll({
target:'body',
duration:1000,
queue:true,
hash:true,
easing:'easeInOutExpo',
offset: {left: 0, top: -55}
});
I'm using Wordpress page templates to pull posts with certain categories into their own page. My problem is that they are also showing on the home page. I know how to hide categories from the home page entirely, but I'd like a toggle so that if it's checked, it will post to home page and sub-page and if it's not checked, it will display only on the sub-page. Does that make sense?
This code is on the "Awards" template and pulls in posts containing the category slug "awards".
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args= array(
'category_name' => 'awards', // Change these category SLUGS to suit your use.
'paged' => $paged
);
query_posts($args);?>
The "awards" category is then blocked from the home page using a query_posts tag:
<?php if ( is_home() ){
query_posts( 'cat=-5' ); //-5 is the category id for 'awards'
}?>
I tried to get around this by also tagging the post with a category that isn't blocked from the home page, but it apparently doesn't care that it's tagged with something else.
So my conundrum is that I would like a simple option (hah) that allows me to pick and choose if it belongs on the home page or not, while still having them all show on this other page.
Well.. in the middle of writing this, I was inspired and sure enough I found the simple solution. 'Uncategorized' is the default category and has the id of 1. On the index page, I simply added the 'query_posts( 'cat=1' );' underneath the bit of code that blocks the other categories. This way, I can tag it for the category I want on one of the sub pages, but also for ones that I want to show on the homepage. Here is the code as it is on my index.php:
<?php if ( is_home() ){
query_posts( 'cat=-5' );
query_posts( 'cat=1' );
}?>
So if I want it on the home page AND the subpage, I'll categorize it as 'awards' AND 'Uncategorized' (or whatever you choose to be the homepage category). If I want it only on the subpage, I just choose that category. This works because the 'query_posts( 'cat=1' );' is written below the 'query_posts( 'cat=-5' );' part, so it's happening after the block which tells the server to display it after all.
Is it an option to use a Wordpress Plugin?
If so, you can use WP Hide Post, which enables a feature to hide certain posts to show on the frontpage.
Here is the link to the resource:
http://wordpress.org/plugins/wp-hide-post/
I have a Wordpress theme that I've been making 'my own' visually and can't seem to get the main content section to display regular posts only - instead of the boxes.
Does anyone know how I can change this without messing it up completely? I've tried stripping everything away and replacing with the 'display all posts loop' thing, but no go. I've tried adding a new page and setting that to show posts and such, but that didn't work either ... all it did was show the latest post.
Any ideas?
Thanks, Jennifer
It depends on what theme you are editing to make your own. If you were editing the default theme one way to do it would be to open index.php, define the template name with something like:
<?php
/*
Template Name: home
*/
?>
and then save it as home.php. In your admin Reading settings set that as your home page.
I am not sure what you mean by "boxes" but I assume you are not interested in the sidebar?
In this file there is one main loop running and it is set to retrieve only the latest post and a sidebar. It pulls in the title of that post : the_title(); the content : the_content(); and the sidebar get_sidebar();. What do you mean by "regular posts"? If you wanted the home page to pull a selection of latest posts you would create your own loop using WP_Query.. something like :
<?php $the_query = new WP_Query('cat=3&showposts=5');
while ($the_query->have_posts()) : $the_query->the_post();?>
Where you are interested in defining the category id (3) and the number of posts to show (5). You can read more on creating these kind of loops here
http://codex.wordpress.org/Template_Tags/query_posts
Good luck :)