Wordpress show post without widgets, header, footer - wordpress

We use Wordpress for the company blog. We would like to show some of the posts in a popover (or light box) on another website. To do that, we need to be able to show just the post's contents without the widgets, header, footer, etc.
So, for example, look at this post:
http://wordpress.org/news/2014/07/wordpress-4-0-beta-1/
Imagine being able to use a special URL, like http://wordpress.org/news/2014/07/wordpress-4-0-beta-1/?postOnly=true where the top header would be removed (the black stuff), all the widgets on the side bar, the entire footer, etc.
Only thing remaining would be the headline, when posted and by who, and the actual post contents.
Any ideas?

Create a very simple page template with code similar to this:
<?php
/*
Template Name: Clean Page Template
*/
wp_head();
if (have_posts()) :
while (have_posts()) : the_post();
the_content();
endwhile;
endif;
wp_footer();
Then just set this template in the post edit screen.

If You can modify theme You're using it's simple to do - just check if postOnly parameter is set and set to true in places that render header, footer etc. If so, simply don't render it.

Related

wordpress custom pre-fixed templates

I want to create a page template that has a pre-fixed css. Lets say I name it page-sevencol.php then I know that the content will have a fixed width and a specific style and so on. My pages have different layouts thats why I need to create these kind of templates.
Is it possible? if so how? Ive looked in the wp codex and it does not seem to have the answer. Please take a minute to help me.
Thank you!
you seem to need just a limited set of templates. The question is: do you want to apply them automatically? Basically, there are two techniques to apply a template to a page (or post or custom post, etc.) in WordPress.
First method: using the template naming convention to get the template automatically applied to a page (or post) with the same name.
In this case, you create a page page-mynewpage.php and this template will automatically get applied to your page named /mynewpage/.
Second method: you create a template by creating a page (let's say : template1.php) and declaring it as a template with a comment at the top of the page:
/**
* Template Name: Template1
*
*/
This template will now be selectable inside the admin of WordPress to be applied to any page:
So if A) you only need a limited set of templates & B) are ok to select them on a per-page basis in the admin, this is your solution. You would just need to create as many pages as you need templates, not forgetting to include the comments that declare them as templates and using a different name each time.
If you need your templates to be applied dynamically, then we need more info about the logic to use for select each template...
EDIT : That is it, Abel (just read your comment). Your page is mainly generated with 4 elements: header.php, sidebar.php, footer.php and another page to produce the content, but this page is different depending on where you are in the site. If you are on a page, it will be, by default, page.php. If you are reading a post, WordPress will by default use single.php.
To apply all your different templates, just go and open page.php in your theme folder. Save it under another name, like page-template7cols.php. Insert a comment like I just explained above, so this template will show in your admin next time you create a new page. Adapt it the way you want (changing the HTML / PHP and therefore adapting the way the content of the page will be displayed). Do the same for your other 9 templates.
Then, everytime you create a new page, just start by selecting the proper template in your dropdown (see previous screen capture). And whenever you will make a change to page-template7cols.php, for example, the changes will be reflected on all pages for which you have selected this template.
/**
Template Name: Template1
*/
<?php get_header(); ?>
<div class="content-wrap sevencol clearfix">
<div class="row clearfix">
<div class="content">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endwhile; endif; ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

one post into an iframe in wordpress

in wordpress how can I load an one post into lightbox iframe, like www.wookmark.com, when click on details and opening the lightbox with post and related posts. I did so, in lndex.php I set the loop <?php the_content();?> then in that loop I write the second <?php the_content();?> which made dabsolute and display none, then with javascript I am callling the div with second <?php the_content();?> and appears the post...but I want the post as in single.php, I mean that navigation links in it open the next post in iframe and not in main page, I have also tried to call iframe putting in it in that case the whole single.php loaded in iframe, with header, footer and navigatin menu, but I just want only the content, how can I relazie that,?
I didn't understand your question, but if you want your posts to display in home page like in www.wookmark.com you can use
query post

Wordpress ignoring page template from drop down

I am struggling with something that appears to be easy, page templates. I have read plently posts on this, people seem to forget to put the comment at the top of the page and can't get it to show up in the drop down menu on pages. I can do this, my problem is the next stage.
I have written the most basic template (custom-page.php):
<?php
/*
Template Name: Test template
*/
?>
<?php get_header(); ?>
<h1>Teams!</h1>
<?php get_footer(); ?>
It shows up and I can select it on the new page sidebar. However when I visit that new page it seems to have defaulted the archive page using the content template include.
Thanks in advance.
If you put the following in your footer, you should be able to grok some further information about how your template is being selected (and know exactly what might be happening).
<?php global $template;
echo(basename($template)); ?>
Then look for the template name in your footer. It's possible (like #adomnom said) that you have a slug conflict. There are a handful of other strange scenarios that could be caused by plugins, custom functions, or other factors as well.
By the sounds of things, it could be conflicting with another template.
For example, if your page has the slug 'category' and is set to use the custom template 'custom-template.php', it would conflict with (and be overridden by) category.php, which is the default template for showing posts for a specific category.
I recommend changing the slug to see if that's the problem.

How to remove sidebar from certain pages and adjust post width div?

I'm trying to remove the sidebar from certain pages and once it is removed the width of the post div readjusts. How to do this?
For pages you can create different template and use it with a specific pages. For posts you can use a custom field to mark pages that requires no sidebar, then read this custom field in your single.php and make corresponding layout adjustments. Hope you know how to do it.
You can use the simple PHP script in page.php to remove the sidebar from specific page.. Here is the PHP script-
<?php if (is_page('your_page_name')) { ?>
<? } else { ?>
<?php get_sidebar(); ?>
<? } ?>
Here is the complete tutorial on removing the wordpress sidebar from specific page http://masterblogster.com/how-to-hide-sidebar-on-particular-page-in-wordpress/

Want to use categories as pages in WordPress

I have a couple of pages (home, about me, ...) in my main navigation. Now I'd like to get rid of my sidebar and I have plenty of space in my main navigation. Is there any chance I could get my categories to display in there, preferably with the subcategories displaying as childs (which will work well in the dropdown menu I have)?
Appreciated!
<?php wp_list_cats(); ?> will list your categories. It will however list them vertically so you'll need to use css in your style sheet to create a class to list the horizontally.
As for removing the side bar. If you go to your index.php and your single.php you will set something like <?php sidebar(); ?> or <?php get_sidebar(); ?> by removing this the page will no longer fetch your side bar. I would personally not advise deleting the sidebar.php file(if you have one) or deleting this line of code for formatting reasons. It is probably best to comment it out that way you can add it back if you ever decide you want a sidebar again.

Resources