Thesis 1.8 has lots of great new features, but one of the less publicised ones is the range of filters that has been extended. These filters make it possible to customise even more of Thesis’ output without modifying core files.
Previously, squeeze pages or landing pages that varied significantly from the rest of your site’s layout might have needed a custom template, a whole new page template, or a bit of a fudge by hiding parts of the page with CSS. Now, it’s really easy to selectively remove the header, sidebars and footer.
Squeeze Page
To get the simplest squeeze page possible: no header, sidebars or footer. Paste the following PHP in custom_functions.php. This code is a modification of code found in the DIYthemes forum.
function custom_remove_defaults($content) {
return false;
}
function apply_custom_filters() {
if (is_page('Squeeze Page')) {
add_filter('thesis_show_header', 'custom_remove_defaults');
add_filter('thesis_show_sidebars', 'custom_remove_defaults');
add_filter('thesis_show_footer', 'custom_remove_defaults');
}
}
add_action('template_redirect','apply_custom_filters');
The first function is the filter that returns “false” instead of returning the content that would normal be there (in the header, or footer, or sidebar). Read more about filters in the Thesis user manual.
The second function selects the page on which to apply the filter and then applies the filter to the header, sidebars and footer, just before Thesis loads on that page. Change “Squeeze Page” in if (is_page('Squeeze Page'))
to the title of your squeeze page. If you want to filter multiple pages you can add their names as an array. E.g., if (is_page(array('Squeeze Page','Second Squeeze Page','Magical Landing Page')))
.
Easily assign many squeeze pages
To more easily assign pages as squeeze pages, when you’re creating the page you can add a custom field to the page and have your custom function detect it. Change the code in custom_functions.php to the following.
function custom_remove_defaults($content) {
return false;
}
function apply_custom_filters() {
global $wp_query;
$squeeze = get_post_meta($wp_query->post->ID, 'squeeze-page', true);
if ($squeeze) {
add_filter('thesis_show_header', 'custom_remove_defaults');
add_filter('thesis_show_sidebars', 'custom_remove_defaults');
add_filter('thesis_show_footer', 'custom_remove_defaults');
}
}
add_action('template_redirect','apply_custom_filters');
Then when creating or editing your squeeze page add a custom field with the name “squeeze-page” and any value (it doesn’t matter what the value is because we only use the name).
Using this set up, every page with this custom field will have the header, footer and sidebars removed.
These pages can be styled individually by using the page name body class, or styled together using a body class filter. See Using Custom CSS Classes for Posts and Pages and the body class filter in the landing page code below.
Landing pages with different sidebars
To present a different sidebar on squeeze or landing pages you could use the Widget Logic or Dynamic Widgets plugins to designate which pages widgets should be displayed on, but if you have many landing pages, or many widgets, that could be labour intensive. So, you can create a whole new sidebar that gets displayed according to the page name or custom field assignment, like the squeeze page filters above. Widgets in these sidebars will only be displayed on your landing pages.
The following code for a landing page — without header, original sidebars and footer and with new sidebars added — goes in custom_functions.php. Note: I’m using different variables and custom field names than in the code above, so pay attention if trying to mix and match the code.
Update 25th October 2010: Added id
parameter to register_sidebars()
and changed IDs in thesis_default_widget()
to avoid confusion with other registered widget areas with sequentially numbered IDs.
Update 3rd November 2011: Edited the ‘name’ parameter in register_sidebars
to fix disappearing widgets problem.
function custom_body_classes($classes) {
$classes[] = "landing-page";
return $classes;
}
function custom_remove_defaults($content) {
return false;
}
register_sidebars(2,
array(
'name' => sprintf(__('Landing Page %d'), $i ),
'id' => 'landing-page-$i',
'before_widget' => '<li class="widget %2$s" id="%1$s">',
'after_widget' => '</li>',
'before_title' => '<h3>',
'after_title' => '</h3>'
)
);
function landing_page_sidebar() {
?>
</div> <!-- custom end #content -->
<div id="sidebars">
<div id="sidebar_1" class="sidebar">
<ul class="sidebar_list">
<?php thesis_default_widget('landing-page-1'); ?>
</ul>
</div>
<div id="sidebar_2" class="sidebar">
<ul class="sidebar_list">
<?php thesis_default_widget('landing-page-2'); ?>
</ul>
</div>
</div>
<div> <!-- balance out #content divs -->
<?php
}
function apply_custom_filters() {
global $wp_query;
$landing = get_post_meta($wp_query->post->ID, 'landing-page', true);
if ($landing) {
// remove unwanted sections
add_filter('thesis_show_header', 'custom_remove_defaults');
add_filter('thesis_show_sidebars', 'custom_remove_defaults');
add_filter('thesis_show_footer', 'custom_remove_defaults');
//add custom body class
add_filter('thesis_body_classes','custom_body_classes');
// add new sidebars
add_action('thesis_hook_after_content','landing_page_sidebar');
}
}
add_action('template_redirect','apply_custom_filters');
This code does the following to pages with a custom field named “landing-page”.
- adds a body class of “landing-page”
- removes the header, sidebars, and footer
- registers 2 new sidebars called Landing Page 1 and Lading Page 2
- builds the code for the new sidebars (note that an extra
</div>
and<div>
are added because there’s no hook in between the end of#content
and the end of#content_box
) - then implements all of the above before Thesis loads
Editing the sidebars
If you only have one sidebar, you can remove the HTML for the second sidebar by deleting
<div id="sidebar_2" class="sidebar">
<ul class="sidebar_list">
<?php thesis_default_widget('landing-page-2'); ?>
</ul>
</div>
If you want a sidebar | content | sidebar arrangement, you’ll need different markup. Ask in the comments.
Landing page CSS
When you implement the above you will find that the new sidebars are below the content. This is because removing the original sidebars activates the No Sidebar template and makes the content full-width. To fix this we need to find out what the width of #content
in your Thesis layout was. Use Firebug in Firefox or Webkit Inspector in Safari or Chrome to find that width by right clicking in the content area and selecting “Inspect Element”.
Then add the width back into custom.css.
.landing-page .no_sidebars #content {width:51.3em;}
Except for adding your content and styling the page, that’s about it. Content is added as per usual, by editing the page in the WordPress dashboard.
John Sexton says
Hey Kristarella,
Great post as always!
I’ll just point out that this could also be extended to posts. In that case you could also use a tag or category of “squeeze” or something similar to activate the filters.
Most people will probably want to use pages, but posts are a possibility to.
kristarella says
Thanks John! That’s a good point 🙂
Mark Williams says
Excellent info as always Kristarella – that makes it a hell of a lot easier to do a landing page for an adwords campaign, etc, than customising a template – keep up the good work! 😉
John says
Thanks Kristarella – great post, exactly what I need too – you’ve helped a non-programmer see the php light!
Kopepasah says
Kristarella,
Excellent tutorial. I was amazed at all the new features in thesis 1.8. I love using filters, and was espically excited to see the ease of the new archives templates markup.
Thanks for a great tutorial.
Oscar Gonzalez says
Excellent tutorial as always Kristen! Greetings.
Tracy says
What a great tutorial! Thanks, Kristen.
I would love to see how people use this. I hope you all will post links.
Cheers,
Tracy
Byron Coke says
Hi Kristarella,
Appreciate the quick tutorial, it helped me solve something I’d spent the last couple of days working on and encouraged me to switch to 1.8.
I was wondering if you could adapt the procedure to remove titles from selected pages or posts. The principle I understand but I couldn’t see a filter from the DIYthemes documentation that would be appropriate.
Byron
kristarella says
Byron — You can filter the headline area. 🙂
Byron Coke says
Kristarella, thanks it worked like a charm.
Jack Aubrey says
Wow Kristarella —
This is awesome. I’ve been hemming and hawing over doing a one-sidebar custom template for a while now, dragging my feet in hopes that something like that would be incorporate into the core thesis functionality. I’ve resisted doing it myself because custom templates seem like such a hassle and a headache in terms of forward compatibility.
This, however, seems like it would do the trick. A quick question. Do you think doing it this way will run into any trouble with future upgrades, etc?
I’m still fairly a newbie at this sort of thing…
kristarella says
Jack, I don’t think there’ll be a problem with this in the future. May be better ways will come up in the future, but at the moment I think this is the best way and reasonably future proof.
Jack Aubrey says
Thanks Kristarella — that sounds like a fairly good approach. Doesn’t make much sense to wait for something better if this works reasonably well.
One quick question: in looking over the code above, which would I use for a one-sidebar design (my normal site goes content-sidebar-sidebar)? I want to keep the header, footer and everything else, but just drop down to one sidebar?
Thanks!
JA
kristarella says
Jack — Yep, the code above works, just delete the second sidebar and make the first sidebar wider with CSS to make up the difference of the previous 2 sidebars. There’s a bit about it in this forum thread too.
Chris P. says
This is great. Sounds like 1.8 and filters are going to allow us to a kind of custom post template.
My goal is to remove a sidebar one the posts pages. Basically converting our normal, sidebar – content – sidebar layout to sidebar – content. Giving our content the extra space taken up by the 2nd sidebar.
So I’ve used your code for assigning many squeeze pages. It works but unfortunately applying the custom field to one post has then removed sidebars across the entire site, including our home page, that is of course full of post excerpts.
Can I use these filters to remove a sidebar only when viewing the full post page? Do I need to modify your code to maybe include categories?
Any help would be greatly appreciated!
Thanks
kristarella says
Chris — Interesting use case. I wasn’t thinking that much about posts when I did this, so I didn’t think of that side effect… should be easily fixed by adding
&& is_singular()
to one of the conditionals. So, it’ll beif ($landing && is_singular()) {
orif ($squeeze && is_singular()) {
in the function activating the filters. That way they should only affect single post/page/attachment pages and not the home or archive pages.Chris P. says
Brilliant! This worked. Now I just need to figure out how to just remove sidebar_2 and leave sidebar_1 and I think I’m set!
Thanks for your quick response!
paul says
you shouldn’t have to add a class to the body manually, as the WordPress body_class() function should generate all the necessary classes for you. Unfortunately, this is broken in Thesis. To repair that, you should add this function in custom_functions.php:
function my_body_class( $class = ” ) {
// Separates classes with a single space, collates classes for body element
return join( ‘ ‘, get_body_class( $class ) ) . ‘"’;
}
add_filter(‘thesis_body_classes’,’my_body_class’);
thisi will generate the following classes : home page page-id-5 page-template page-template-customtemplate-php logged-in custom home
the “page-id-5” can be used to style individual pages
kristarella says
Paul — I’m not sure if the omission is an oversight or a conscious decision to avoid clutter, but thanks for the heads up! I’m sure that will come in handy.
Karina from Sydney says
Great Content and I did like the invitation to subscribe to this feed. I believe that we bloggers tend to underestimate this tool that the best part is that is free but it counts for SEO. Thanks!
Ronald Lee says
Hi there,
Great, thanks for the tutorial on how to make squeeze pages.
A question on how to use it…would you use it as the MAIN landing page for your site all the time? Or just a landing page that you send people to only that isn’t the main page?
For example, I’d like to have my site go to the squeeze page the first time visitors go to it so I can collect their info. However, after then, I’d like to allow them to just see the website with a regular non-squeeze home page. Is that possible?
kristarella says
Ronald — You could use this on the main page of your site if you want the layout to be different to the rest of the site, but it would traditionally be a sub-page of the site where the link might be placed on a profile elsewhere, like Twitter, you could have a Twitter specific landing page.
To make a new user landing page you would probably have to use cookies to determine whether the person has been to your site before and if they haven’t you can redirect them to the other page. To give you a general (and possibly specific enough to execute) idea: PHP Cookies, then maybe use a meta tag to refresh the page to a new URL if the cookie doesn’t exist.
Some things to keep in mind are that the cookie would want to have a pretty long life, but people clear their cookies occasionally, so it wouldn’t be fool-proof. Also, it’s worth weighing up when and where is the most appropriate time to do that: it’s probably only suitable on the home page, because if someone came to an internal page from Google or another source wanting to read what was on the page and got redirected away, that would be more than annoying.
kristarella says
Ronald — Or the really simple, non-technical, way of doing it would be to create the page and just give that URL to everyone and every site where you have your URL. That wouldn’t only get new users, but all users that are coming into your “homepage” from another source, like Twitter, Facebook, Linked In etc. When they get there they would notice that they weren’t on the homepage and go check that out when they’ve seen the page their on.
Ronald Lee says
Great ideas Krista!
Thank you!!!
Jeremy says
Wow, this is perfect. I have a couple questions though – I got the filter to work correctly, but I would like to change the width of the new single sidebar and the content. (Most pages are Content Sidebar Sidebar) I see above you said to do that in the CSS – could you give a rookie some insight? I have no idea what code I’d edit or where to put new code (or what the code would be).
Thanks!
Jeremy says
Follow up: here’s the page I am implementing the filter on: http://thefrugalfind.com/the-f.....pon-class/
Not sure if that matters or not, but figured it won’t hurt. I’d like the sidebar to be on the right side of the page, possibly 1.5 times the width it currently is, and then have the content be able to take up the rest of the space.
kristarella says
Jeremy — Try the following CSS in custom.css:
You can change the widths of #content and #sidebars until it seems right to you. If you add to one, take away from the other.
Jeremy says
That’s great! Is there a way to make it apply to all pages that have the video-page custom field? I’m going to have about 10 pages that I need to have the same styling and sidebar on, just don’t have them created yet.
Jeremy says
Ok so I entered the code you gave me, but nothing changed. I cleared my cache (backend – I use W3 Total Cache) and did a hard refresh, it looks exactly like it did before I entered the code. Also, I don’t seem to be able to edit the widget. I have new widgets in my widget area, video Page 1 and video Page 2, and I added some text to both but the default text still shows up in the widget on the page.
kristarella says
Jeremy — Woops. I didn’t see the ” video-page” bit in the CSS or in the body class.
That should work on all pages that you give the class & field to.
The widget area ID depends on how many widget areas you have registered and what order they’re registered in. It looks like you might have several widget areas in your footer, so you need to figure out what number the new widget area is: Thesis has the first 2, then any that are registered before this one. If you have 4 widget areas in your footer and no others, then it might be sidebar 7 and you’ll need to change the ID in
thesis_default_widget(3);
.Jeremy says
Woohoo! You’re right on the widgets, that one is actually #7. Thanks SO MUCH for your blog. Amazing stuff!
karen says
Hi Krista,
I was able to make the landing page/squeeze page/home page/front page (there are so many names for this page ;P) just the way i want it – without content, nav bar or sidebar but now, it affected the SEO and ranking has dropped since there’s no content on the front page.
Any ideas about how to rectify this?
kristarella says
Karen,
I don’t know how the amount of home page content affects page rank. It’s conceivable that no content might reduce it because there’s less for Google to assess relevance on. However if the internal content is still there, then the URL should have about the same authority.
I have heard that changing the HTML of the page can cause a drop in rank, often temporary. It also depends what other people are linking to on your site. If they were all linking to the homepage and none of the same content is there, Google might decide those links are not as relevant as before (maybe a temporary reassessment).
That is mostly guessing on my part (but much supposed SEO advice is I suspect).
I found an SEOmoz question that looked relevant, but I don’t have pro membership to see the answer. If you do, check that out.
You seem to have good title and description in the page’s meta data, but they are the only two things on the page that say what your site is about. Maybe the image could do with some alternate text as well.
The only way to really test it would be to try adding more content and see if it makes a difference, but it’s not an easy test since the effects are not immediate.
That’s about all I have for now.
Ron says
I am not sure if this squeeze page code is what i need or not.
i am trying to make the home page, show only the far background and nav, but i want to be able to write content on a transparent background content area (only on the home page).
thanks, ron
kristarella says
Ron — I think you probably just need
.custom .full_width .page {background:transparent}
and maybe uncheck the options to display the internal borders (in the design options).ron says
ok, but how do i set that for one page only, not the entire website?
i need to turn off internal borders and side bars for the one page only also.
thanks, ron
Ron says
i got it, except for one problem… a little peace of the top of the page shows where page title is.
thanks, ron
karen says
Thanks Krista,
I’m going to play with some content as suggested on the DIY Forum – about 100 words or so….and see what happens.
Ron says
i got it… i dont know if i did it the best way, but it looks how i want it.
when you got time can you look at my code and see if it is ok.
thanks, ron
John says
Hi kristarella – if i want more than one landing page, how would i define the second, third etc. – could i do it in this section like this:
function custom_body_classes($classes) {
$classes[] = “landing-page1; landing-page2; landing-page3”;
return $classes;
}
kristarella says
Hey John,
In what way do you want more than one landing page? Do you want to style them differently, have different sidebars on each, or just different content,
The code you’re referring to only has to do with style. Your modification is not quite right, but if I know what you mean I’ll point you in the right direction.
Chris says
Thanks for the tutorial…I love this site.
Would the above strip everything of the page — sort of a blank canvas ?
kristarella says
Chris — The code in the post removes the header, footer and sidebars, but other custom styles (such as a site or page background colour) will still be there. The best way to remove those custom styles for a truly blank slate is to override them using CSS and the custom class given to the page.
John says
Hi kristarella – i want to style them differently and have different sidebars etc (so i would like the ability to change both the php & css for all LPs) – and then, when I’m adding a new page, when i go to Custom Fields i can just add whatever the Landing page name is as the custom field for that particular page that i’m working on, i.e. i would put landing-page1, landing-page2, etc. into the custom field section.
John says
sorry, just realised, that may have been slightly confusing – i should have said i want to be able to choose from a few different landing pages when entering the landing page name in the custom field, so obviously i would choose either landing-page1 or landing-page2 or landing-page3, etc. when i’m in the Edit Page section.
kristarella says
John — The code above was designed to be most efficient for creating many pages with the same layout, which is different to the main blog & pages layout. And so that you would only ever need to use one value to define those pages: the custom field.
If you want to make several pages, each with a slightly different layout, or make several different layouts that may be used on multiple pages at will, I think you’d need a different approach to each.
For the first option — multiple pages, each with a different layout or different widgets — I would first register the landing page sidebars, just one set of landing page sidebars, and then use Widget Logic or a similar plugin to declare which widgets to display on which landing pages. And then since each page is given a body class of the page’s name (lowercase with hyphens instead of space) you can use that class to style each page.
For the second option — multiple landing page templates to be used on any pages with a particular custom field — I would utilise both the custom field name and value to determine it’s a landing page, and then determine which landing page template to use. The code would be something like:
The changes I’ve made there are:
Fetch the custom field with the name “landing-page” and use the value (which will be “landing-page-1” or “landing-page-2” etc) as the class that will be added to the body
Registered 4 sidebars instead of 2. This will vary depending on your needs, but the above code adds two new and different sidebars to each type of landing page. So, 4 sidebars is for 2 different landing pages each with 2 sidebars.
Then I’ve defined the IDs for each type of landing page. landing-page-1 uses the sidebars called Landing Page 1 and Landing Page 2, the IDs for those are 3 and 4 and are added to the
thesis_default_widget()
function by way of a variable. You need to add a new line ofif ($landing == 'landing-page-1') { $sidebar_1 = 3; $sidebar_2 = 4; }
for each new landing page type.If that’s all getting way too complicated for what you want to achieve on your site, then maybe you need to have some regular page templates made that will show up in the page template dropdown. As I mentioned, the code in the post was designed to be efficient for multiple pages of similar style, and it’s more forward compatible than making a page template, which I’ve found can be not very forward compatible. It may not be the most efficient for pages of very different style.
John says
Hi Kristarella – first of all, wow, you’re a star, and i feel guilty looking at everything you’re doing for free here, so a big thank you!
I think I may just be complicating things more than i need to, on reflection – i think having different styling in the css would be enough for me, but i’m still a bit confused as to how i define “landing-Page-1” and “landing-page-2” in custom-functions if i just want to change the style?
When i go to custom.css I already have my style set for .landing-page, and i now want to setup styling for .landing-page-1, .landing-page-2, etc – which is all fine, no problems doing that – but defining them in custom functions is still a bit confusing to me – i think your explanation is great for more complicated structures, but more than what i need right now, but useful to know for the future.
So I guess all i need to know right now is how to define more than one landing page style in the custom_functions.php file.
Thanks again!
kristarella says
John — If you only want to do custom styles then you can use the CSS class field in the Thesis meta box on the page editing page, under the content entry box, or as I mentioned, just the page’s own name, which is already added as a body class. You don’t have to use the filter in the functions file to add a class.
John says
god, i’m an idiot, i’ve finally figured it out – i was confusing the term “landing-page” in custom_functions with the style term “landing-page” in custom css – i thought they were related terms in that the css name had to be the same as the name defined in custom_functions, but actually the css style name doesn’t have to be the same at all – that’s why i was thinking you had to define the style first in custom_functions – but obviously not the case – i was overcomplicating things as usual – the heavy fog just lifted a bit, thank you. (i’ll get the hang of this stuff eventually).
kristarella says
John — Sorry for the confusion! Glad it clicked for you 🙂
Emeric says
Is there any reason that the header, sidebar, or footer would not be removed while using this filter?
I’m using the ‘landing-page’ code and filter and I can not get the header and sidebars to disappear. However, the additional side bars are showing up.
Here is the page that is being dismissive: http://www.firsttimewebdesign.com/wanderings/
kristarella says
Emeric — Upgrade to Thesis 1.8. You’re only on the beta, it may not have the filters.
Emeric says
You’re a genius! And I’m… Grateful. Thank You.
Joshua Nelson says
Kristarella,
This is great! Thank you so much for putting it together! Two questions:
I have the multimedia box on the other pages, but how can I add it on the landing-pages? This is probably a bit of a dumb question, but I’m still getting used to all the thesis functions/hooks/filters.
Also, for some reason the WordPress Admin link is appearing in the footer on the landing page, even though I have this option unselected in my design options. Note: I am using a draft preview of the page, but that shouldn’t matter.
Thanks,
Joshua
kristarella says
Joshua — Add
<?php thesis_multimedia_box(); ?>
after<div id="sidebars">
to your sidebar code.I don’t know about the admin link. Let me know if it shows on a proper published version of the page.
Joshua D Nelson says
Kristarella,
Thanks! That works. I figured out the wordpress admin thing, just some erroneous code on my part.
Cheers,
Joshua
kristarella says
Hello all, just a brief note: I added id parameter to register_sidebars() and changed IDs in thesis_default_widget() in the code in the post to avoid confusion with other registered widget areas with sequentially numbered IDs. Anyone who had problems with that before might want to check out the new code and update theirs for future clarity.
Lisa says
Hi Kristarella
Thanks for all your posts. What I’d really like to know is if there is a way to remove the sidebar from specific posts rather than pages. If not is there a way to ‘feature’ pages rather than posts , ie as teasers, on the homepage. Any explanation needs to be dummy proof:)
kristarella says
Lisa — Yes, you can do it the same way for a post as for a page: by adding a custom field or by using the Conditional Tag for a single post. Also, if you use for posts it can sometimes affect the home page so use the code in comment 16 to avoid that.
Not sure if that is dummy proof since my answer was “it’s almost the same”. Feel free to follow up with questions when you try to tackle the code.
Lisa says
Hmmm. Not dummy -proof enough I’m afraid. I think on balance I had better re-think my layout but thanks for taking the time to reply.
kristarella says
Lisa — Combining the PHP you’d need for no sidebar on posts + not messing up the home page, it’d be:
Then add a custom field to the post with the name “squeeze-page”. Custom fields are added on the post editing page, down below the content entry and Thesis fields.
That’s it.
Edward Beckett - Florida SEO says
Kristerella …
I’ve been hacking Chris Pearson’s Themes for a couple years … and Thesis for a while too and I’ve got to tell ya’ that you produce some of the best tutorials on the subject
Thanks for the great share(s)
🙂
EB
LeeCheng says
Hi Kris,
I followed your steps and i have 2 sidebars, Landing Page 1 and Landing Page 2. Under Widgets page, i drag and drop widgets into sidebars Landing Page 1 and Landing Page 2. But when I click to other pages and come back to Widgets page, I found my widgets disappeared from the 2 sidebars. It doesn’t stay. But when I visit the my site, I see my widgets there. I left it for a while until one day I found the widgets disppeared from my site as well.
Can you help me please?
Trac says
Have any of you folks found a good way to layout your page in multiple columns, newspaper/magazine style?
Thanks.
Filippo says
Hi Kristarella,
I’m using your code to obtain a single squeeze page, but the sidebar didn’t disappear. I tried with “sidebars”, “sidebar_1”, “sidebar_2”, but nothing. Do you know why this? This is the link for the page (I made it as clean as possible since I’m using it with the shadowbox’s iframe): http://elsatrento.org/newsletter
Micky H Corbett says
Hi Kristarella,
First off I’d like to say this tutorial helped me a lot as I now do my landing pages within wordpress with Thesis. And for anyone who doesn’t know there is a plugin that does split tests in wordpress that works a treat! It’s called Google Website Optimizer For WordPress.
Anyway what I wanted to say is that I used your landing page code and added a little twist that I hope people will use as well.
For my main site here I replaced the header with a header function that as you can see has a logo, headline and an opt-in box. The logo and headline are images and the opt-in is a typical email subscription script.
For the landing page I wanted to remove the sidebars, the nav and the header but I wanted a way to still have a headline.
So what i do is I modify my header function to read the “squeeze-page” field and also use the information in the field, which is a link to a headline image, to replace the standard header. It does this be echoing the “squeeze” variable defined in the function.
Then I also call your function that removes the sidebars and nav by filtering.
I currently use the same headline image in a number of pages (as it converts pretty well) but here is an example of the page to show you guys what it looks like. By the way the headline also links to home.
I recognise I could have made the functions a bit cleaner but it works. Also for anyone not familiar with the “get_post_meta” function, if you make the last parameter false it will read in an array of data. Make it true and it reads in the first line. So you could effectively have lines of code here that get echoed. I don’t really know though. I just use a headline image.
Here’s the code:
/* custom header */
remove_action(‘thesis_hook_before_header’, ‘thesis_nav_menu’);
function optin_header () {
global $wp_query;
$squeeze = get_post_meta($wp_query->post->ID, ‘squeeze-page’, true);
if ($squeeze) {
?>
<div id="optin-header">
<table>
<tbody>
<tr>
<td width="150px"></td>
<td width="640px" align="middle">
<a href="http://flatbellyfast.org" title="Flat Belly Fast Home Page">
<img src="<?php echo $squeeze ?>"></a>
</td>
<td width="150px"></td>
</tr>
</tbody>
</table>
</div>
<?php
}
else {
?>
<div id="optin-header">
<table>
<tbody>
<tr><td>
<a href="http://flatbellyfast.org" title="Flat Belly Fast Home Page">
<img src="http://flatbellyfast.org/wp-co...../a>
</td>
<td>
<img src="http://flatbellyfast.org/wp-co.....t;>
</td>
<td align="center">
<br/>
<script type="text/javascript" src="http://forms.aweber.com/form/4.....pt>
</td>
</tr>
</tbody>
</table>
</div>
<?php
}
}
add_action(‘thesis_hook_before_header’,’optin_header’);
add_action(‘thesis_hook_after_header’, ‘thesis_nav_menu’);
/* squeeze page filter */
function custom_remove_defaults($content) {
return false;
}
function apply_custom_filters() {
global $wp_query;
$squeeze = get_post_meta($wp_query->post->ID, ‘squeeze-page’, true);
if ($squeeze) {
add_filter(‘thesis_show_sidebars’, ‘custom_remove_defaults’);
remove_action(‘thesis_hook_after_header’, ‘thesis_nav_menu’);
}
}
add_action(‘template_redirect’,’apply_custom_filters’);
To remove the page header I suppose you could use a class or if you don’t have a lot of landing pages you can simply go into the css and make the h1 tags white in colour for each page. That way they still show up in the code but not when viewed.
kristarella says
Leecheng — I’ve never heard of that problem before. It might be caused by a faulty plugin.
Trac — There are threads in the forum about writing a custom teaser loop. You could use the custom loop API to make teasers go in 3 columns rather than 2.
Filippo — I can only guess that you were doing it wrong. The filter to remove the sidebars has to be applied to
thesis_show_sidebars
. I’m not sure what you mean by trying “sidebars”, “sidebar_1” and “sidebar_2”.Micky — Thanks for sharing 🙂
Steve says
Hi Kristarella,
I am a complete newb and while I have read this thread numerous times I’m still not I am getting an answer to my question. I also think I may have read it too many times…;o)
To make this very simple I am trying to have my Home Page act as my initial landing page which has no sidebar. I learned that I can check the ‘No Sidebar’ option under the Page Attributes but now I am having other issues. For instance, I can’t seem to get my h2, and other bullet points to display properly and therefore the page does not flow well at all. Following some other direction from another site I was able to create a couple of other pages outside of wordpress using simple HTML editor and that has worked just fine. So I guess my question is if I wanted to have my home page outside of Thesis how would I do this? Or, would it be easier to use the directions above and use a simple HTML editor and copy and past the HTML code in to create my home page but use the Custom Fields option.
Let me know if this does not make sense. I’ve learned a lot from your site, and WAY more than I think I ever wanted to know…. ;o)
Thank you very much!
Steve
Again I am a newbie so this code is WAY over my head…;o)
James says
Kristarella,
I ran into your site a few weeks ago, looking for some customizations. Now I ran into this post because I am looking at setting up some landing pages. Basically it looks like John’s comment/question above about multiple landing pages.
What I am trying to do is blog at my real estate site say realestate.com, then I want to do a redirect so that commercial.com shows all the catagory=”commercial” and luxuryhomes.com shows all the category “luxury”. Is there a way to set this up so that when folks google “luxury” they see a link to luxuryhomes.com and if they google commercial real estate, google serves up commercial.com? Right now, when they google any information on these, they are seeing just realestate.com
Thanks a ton.
James
kristarella says
Steve — You probably don’t need a post as complex as the one above for your home page. You just need to create a page with No Sidebars selected as you already did and then in the Reading Settings for WordPress set that page to be a static home page. Then you should be able to use the Visual editor to lay out the page’s content. But if the visual editor isn’t working well for you, you can try making it in something else and pasting the HTML into WordPress with the editor switched the the HTML editor tab.
A separate home page outside Thesis is probably less practical.
James — I believe that what you want to do is set up those domains to redirect with masking turned on. So luxuryhomes.com redirects to realestate.com/category/luxury, but the masking means that the URL in the address bar doesn’t change to realestate.com. I hope that makes sense for you!
Lee Cheng says
Hi Kristerella, I tried removing one of the line that Girlie from the forum suggested and it worked fine now. Just wanna share it over here.
register_sidebars(2,
array(
‘name’ => ‘Landing Page %d’,
‘id’ => ‘landing-page-$i’, (REMOVED THIS LINE)
‘before_widget’ => ”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”
)
);
Dan says
Kristarella,
Most of your wonderful tutorials have been immeasurably valuable to me, and I’ve long appreciated all the great advice you offer the Thesis community. Sincerely, thank you!
This particular tutorial I’m still a little perplexed following. I’m trying to create a single-page website that will serve no purpose but to collect email addresses via a form so I can notify people when the organization has its official public launch. No blog or other content — that’ll come down the road. I’m using Thesis 1.8 and the current stable release of WordPress (3.0.3 as of right now). I have WordPress set to use a Static home page. I’ve called the page “Landing”.
Design-wise, I need a basic page that fills the whole browser screen (full-width) with no padding or margins. It’ll have a background image stretched to fill the width of the page. And a small box of text centered where I’ll have the organization’s name, a form for entering the email address, and a submit button. In tiny, tiny text on the very bottom will be a simple copyright statement. That’s it. And for whatever reason, it’s not working well for me.
My page has a custom CSS class assigned of “landingpage”, and I’ve tried all sorts of combinations of CSS to make it work.
The first problem, is that I can’t seem to get the header_area to display as none, using:
.landingpage #header_area {display:none;}
The rest of the page is blank — it seems the scrollbars, footer, etc. have been removed using your custom functions from above, as they should be. (I’m using your first block of code found under the “Squeeze Page” header.)
Any help you can offer on the CSS to make the basic page structure I’m after would be much appreciated. I can finesse it from there, but the structure itself (the 100% page layout, background color or image, a basic box of text/form in the center, and the lack of any other page elements) isn’t rendering correctly for me.
Once again, thanks for all that you do for the Thesis community. I’ve benefit so much from your tutorials, I feel embarrassed even asking for help here. So very much appreciated, anything you can offer to get me going in the right direction.
Jordan says
Kristarella,
Great content – really, eye-opening!
My needs are slightly different: I’d like the stuff (widgets) that goes into the two sidebars of a dynamic homepage to be different from what goes into the sidebars of ALL other pages (inside pages, posts, archive, search pages — everything: those are all the same, but different than the homepage). The width and placement of the sidebars don’t change, only the sidebar-content of the homepage vs. all other pages. In fact, the differences can be narrowed down further: It is a different set of widgets that go on the homepage-sidebars than the set of widgets that go the other pages’ sidebars.
Would you use the ‘landing-page approach’ to solve this, or use the Widget Logic or Dynamic Widgets (I’m not familiar with either), or something else, for a situation like this?
Many Thanks!
Jordan
drt says
Hi Kristarella,
I hope you have been recovered and you’re doing ok now.
I have to put a javascript before the html tag in one of the landing page file that I would like to create using Thesis. To simplify it further, I would like to use your code to create a squeez page.
My question is, would the custom filters also remove the codes above the header (even before the <DOCTYPE line)?
I really don't know how to put my script into thesis, particularly before the first html tag and I have posted my question here then got some idea from the answers on how to do it. But just curious it that line would not be removed by your filter above since it’s located before the header?
Many Thanks,
Aris/
Jess says
Hi Kristarella,
We GREATLY appreciate all of your INFORMATIVE and helpful tutorials, a BIG THANK YOU! Unfortunately, I ran into a bit of trouble when attempting to “assign many squeeze pages” to our site. After inputing the indicated code in the custom_functions.php section, I am receiving this error (shown below), and the my page text is black now. I tried going back in to remove the code, however, I cannot get back into the custom_functions.php section at all now : ( Any suggestions as to how to get my site back to normal? Many thanks!
function custom_remove_defaults($content) { return false; } function apply_custom_filters() { global $wp_query; $squeeze = get_post_meta($wp_query->post->ID, ‘squeeze-page’, true); if ($squeeze) { add_filter(‘thesis_show_header’, ‘custom_remove_defaults’); add_filter(‘thesis_show_sidebars’, ‘custom_remove_defaults’); add_filter(‘thesis_show_footer’, ‘custom_remove_defaults’); } } add_action(‘template_redirect’,’apply_custom_filters’);
Warning: Cannot modify header information – headers already sent by (output started at /home/diabrel/public_html/wp-content/themes/thesis_17/custom/custom_functions.php:50) in /home/diabrel/public_html/wp-includes/pluggable.php on line 890
David Alexander says
Hi Kristarella, cannot believe I only came across this post today. Its brilliant, however I have a slightly different requirement which may get messy using this approach entirely.
As I need a different widget on each page I think the best approach would be to use the majority of what you are doing here but also have an additional meta field to popular the custom called sidebar or sidebars.
What I want to do is have the following templates
Default (default) set to 1 sidebar sitewide for the homepage and single posts, archives.
no_sidebars (default)
archives (default)
Then have an alternative 1 sidebar template showing a different sidebar
and a template with 2 sidebars.
I also need to control the content on these custom sidebars, I am exploring how I can use your code with another meta field to populate the custom sidebar or sidebars on a page for page basis.
Any thoughts? I have a few pieces I am going to try, looking at combining this tutorial with
http://www.webhostingsearch.co.....torial.php
Cheers, happy new year. 🙂
Tracy says
You did a great job of making custom templates less scary and for that I am sending you a huge THANK YOU!
I’m off and running with your code bits above to make trouble! (I mean that in the best way….)
Again, many thanks!
Tracy
kristarella says
Dan — Sorry, without a link to see what’s not going right for you I don’t know what to advise.
Jordan — Depending on the number of widgets you’re using on the home page, I would probably use Widget Logic, or Widget Context is even better.
Aris — These filters don’t remove the other HTML of the page. For your purposes you would probably need to create a new page template file in the Thesis folder.
kristarella says
Jess — That error would need to be fixed by accessing custom_functions.php via FTP. Headers already sent can sometimes be caused by extra white space at the end of the functions file, after a
?>
.David — I think that because you want to do multiple things with this you might be best off using a child theme and creating a variety of page templates in that.
Alan says
Kristarella,
Any idea why I would be getting this error
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, ‘custom_remove_defaults’ was given in /home/thedoct/public_html/wp-includes/plugin.php on line 166
I am using the landing page code. The page that is the front page I added a custom field called “landing-page” with field as 1. I have turned all the plugins off to see if it was a plugin conflict, but it only shows up with the code in the custom functions file. If I delete the code everything is back to normal, but then I don’t have the custom front page?
kristarella says
Alan — That error means that the second function name in the
add_action
call is not a defined function. Are you sure you’ve got all the code? You might be missing the first function (containingreturn false;
).Alan says
Have no idea, but loaded a fresh new custom_functions.php file repasted the code and it works, so one of those funky wordpres thesis things that happen every once in awhile. Probably didn’t paste the whole code as you said, but everything is working so thanks so much for the code. This is exactly what I was looking for.
John says
Hi!
I’m playing around with a squeeze page and having trouble. I’m also developing locally (MAMP) so you might not be able to help, but I thought I’d ask anyway.
I’ve created a new page ‘Squeeze Page’ using the default template, and copied your code into custom_functions.php to remove the defaults. I’ve tried all the tricks I can think of, but the header sidebars and footer are still showing. Ideas? Thank you!
function custom_remove_defaults($content) {
return false;
}
function apply_custom_filters() {
if (is_page(‘Squeeze Page’)) {
add_filter(‘thesis_show_header’, ‘custom_remove_defaults’);
add_filter(‘thesis_show_sidebars’, ‘custom_remove_defaults’);
add_filter(‘thesis_show_footer’, ‘custom_remove_defaults’);
}
}
add_action(‘template_redirect’,’apply_custom_filters’);
John says
The problem I mentioned previously, of header-sidebar-footer persistence? Turned out I was using the beta version of Thesis 1.8b instead of 1.8 and I had missed your pointing this out to EMERIC earlier in the thread. All’s well now though.
Three cheers for sharing! Thank you.
kristarella says
John — Sorry I didn’t get a chance to get back to you yet. Glad you found the answer!
Alan says
WOW! Not sure you will be able to help me, but I am a Thesis user & want to migrate another site to Thesis as well. Here’s the situation as posted in the Thesis forum:
Presently with another theme the homepage is configured differently than the posts & pages. Both the homepage & the posts & pages use a 3 column format yet the homepage columns are a different size & placement compared to the rest of the site. The homepage is also widget friendly, including a recent posts widget w/ thumbs. I would also like to add a tabbed widget or something similar, so that I can display more than just recent posts on the homepage.
I don’t want to use the Thesis static homepage option, as that would add “blog” to the url structure of the existing posts. So, can I customize a homepage that will look & function differently than the posts & pages?
Here are some pics of the theme presently being used…
Homepage: http://www dot gazellethemes dot com/wp-content/uploads/magatheme/screenshot2.png
Post: http://www dot gazellethemes dot com/wp-content/uploads/magatheme/screenshot5.png
So, there you have it. From your post above, I am guessing that I can achieve the desired results but, if so, do I have the ability w/o pestering someone such as yourself? 🙂
kristarella says
Alan — If you’re running a standard install of WordPress I don’t believe you automatically get a “blog” added into your URLs. I just tested it on my local install of my website with WordPress 3.1 and the article URLs were the same. I think the “blog” URL thing only happens with WPMU (networked WP sites). Is that the kind of install you have?
So, assuming that there isn’t a URL issue, then using a static homepage and replacing the contents of that page with the custom loop API is the most efficient way to go.
If you still have the URL issue then one way to get around that would be to use the custom loop API to manipulate the contents of the home page and also create another blog page manually.
Check out my post on custom loops and also the Thesis docs on the loop API. Those combined can do what you want.
Alan says
Wow again! Thank you for your reply…I really appreciate it.
You are correct about the blog in the url. I just checked my site presently running Thesis & the only instance where blog is in the url is mysite.com/blog, but the individual posts do not include “blog”
I am not an expert regarding php, html, etc but I can follow directions! So, I will have a look at your posts & see if I think I can handle the mods. Doing what I want to do will probably not be easy for me alone & I haven’t had much response to a couple of threads in the Thesis forum, other than to come here 🙂 I really do want to get my wife’s site to Thesis though as I am concerned about her current theme being not being updated.Thesis is so easy to use & to do basic design, so my wife can point & click & design her own colors & such.
Are you available for any custom work if needed? I will email you a link to her site if you want to have a look, as how it is now is basically how we want it to be w/ Thesis as well. Thanks again!! I really appreciate your reply.
Alan says
Oh My! I read your post on custom loops & w/o a lot of help, that will be over my head! 😮
So, I direct you to the last paragraph in my prior post…unless I am making this more complicated than it is.
Thanks!
kristarella says
Alan — That’s okay. I like to point people towards the answer first to see if they can figure it out, so they can learn more about how to do it, rather than just learning how to copy and paste stuff.
Yes, I can do custom work. I have some unanswered enquiries in my inbox at the moment, but send me an email and don’t stress if I don’t get back to you right away.
Since the URL thing isn’t a problem, I would still go with setting a static home page and making a separate blog page, so that WordPress automates the whole blog side, but you’ll still need some custom loop action on the home page.
Alan says
Thanks!
I am certainly willing to try to customize the home page myself, I would just need, at least to some degree, specific “copy & paste” instructions 🙂
I will send you an email of the site so you can see what I want to do in Thesis.
Jennifer says
Hi Kristarella,
Thank you so much for all your help! THis is so wonderful!
I have one issue. I used the code for creating a landing page and checked the box for no sidebars. I also set the body content to the correct width is custom.css. However, the content is flush to the right of the screen so there’s a huge blank column on the left and no white on the right. I want the text to be centered obviously! Do you have any suggestions?
Thanks much,
Jennifer
Jennifer says
I should also mention that I deleted this code:
To get rid of the sidebars.
Jennifer says
I meant I deleted this –
<div id="sidebars">
<div id="sidebar_1" class="sidebar">
<ul class="sidebar_list">
<?php thesis_default_widget(‘landing-page-1’); ?>
</ul>
</div>
<div id="sidebar_2" class="sidebar">
<ul class="sidebar_list">
<?php thesis_default_widget(‘landing-page-2’); ?>
</ul>
</div>
kristarella says
Jennifer — From your description, I’m guessing something like
.landing-page #content {float:none; margin:0 auto;}
.Jennifer says
Yes! Thanks Kristarella, that did it! You are awesome 🙂
Brandon Cordoba says
Holy crap Kristarella thank you! 🙂
Al says
So much easier than the custom function I was making. Very elegant. Thank you for posting.
Jay says
Thanks a million! This was very helpful and you made it sooo easy :-))
Daryl Lozupone says
How do you remove the comments box? Some of the pages in the blog need to be able to have comments, while the landing pages should not. It seems Thesis removes the meta box for disabling comments on individual pages.
kristarella says
Daryl — Discussion options for pages are still available for each page: the meta box is second or third from the bottom on the page editing page, or second bottom in the right column of the Quick Edit box in WordPress.
Jan says
Your posts are helpful and,of course, the demonstration of how the code is developed gives php newbies like me a place to start hacking things out for themselves. Thank you!
The use of filters here is a wonderful exercise since the users guide is totally truncated on the subject.
Your code as I understand it, removes Thesis’ default header, sidebars and footer:
But what if you wanted to retain the default header?What happens to this line:
“add_filter(‘thesis_show_header’, ‘custom_remove_defaults’);”
if ($landing) {
// remove unwanted sections
add_filter(‘thesis_show_header’, ‘custom_remove_defaults’);
add_filter(‘thesis_show_sidebars’, ‘custom_remove_defaults’);
add_filter(‘thesis_show_footer’, ‘custom_remove_defaults’);
}
kristarella says
Jan — You can either comment out the line by adding
//
at the start of the line, or just delete the whole line.Jan says
Super! I will be putting this to work shortly. Bless ya!
Jan says
So I retained the header, the footer and eliminated the headline area. I wanted only 1 sidebar but the result has me curious. The page seems to want the 2nd sidebar. (I deposited the calendar widget in sidebar1). I wanted to absorb some of the area occupied by sidebar2 into the content column. But that didn’t result
I’m not clear on the content either. Seems I have some adulterated version of the post, albeit with only the comment form. I thought I’d proofed the code but maybe not.
Page is included in website above
kristarella says
Jan — You need some CSS to widen up the sidebar on that page:
.landing-page #sidebar_1 {width:100%; border:0;}
.If you don’t want the comment form on that page, then turn comments off for that page, and it appears there may be some odd characters in your post, perhaps a < at the start that is mucking it up. Double check your post contents in the editor.
Keith Jones says
This looks like just what I need for a new project.
Thank you.
Keith
Jason says
Thanks Kristarella! What if I wanted to retain the header for branding reasons but remove the top navigation only in the header section? I do want the sidebar and footer removed so this is very close. Just need the header back without the navigation. Been stumped on this one. Thank you again!
kristarella says
Jason — You don’t need any of this to remove or move the nav. Take a look at this user manual article.
Jason says
Sorry Kristarella, I don’t think I was clear. I do want to create squeeze pages like you’ve described in this post. I am needing the header on these squeeze pages to appear without the navigation.
So I combined what you provided plus what Thesis provides in the user manual article. Seemed to work like a charm. Thanks!
function custom_remove_defaults($content) {
return false;
}
function apply_custom_filters() {
global $wp_query;
$squeeze = get_post_meta($wp_query->post->ID, ‘squeeze-page’, true);
if ($squeeze) {
//add_filter(‘thesis_show_header’, ‘custom_remove_defaults’);
add_filter(‘thesis_show_sidebars’, ‘custom_remove_defaults’);
add_filter(‘thesis_show_footer’, ‘custom_remove_defaults’);
}
}
add_action(‘template_redirect’,’apply_custom_filters’);
function remove_nav() {
global $wp_query;
$squeeze = get_post_meta($wp_query->post->ID, ‘squeeze-page’, true);
if ($squeeze) {
remove_action(‘thesis_hook_after_header’, ‘navigation’);
}
}
add_action(‘thesis_hook_before_html’,’remove_nav’);
David Newell says
Hi Kristen,
As usual your tutes are thought provoking and thorough. Many, many thanks for that!
It looks to me that your Landing Page code can be used as a ‘Facebook Iframe Welcome Page and landing page combined’, just by limiting the page width to 520px and using no sidebars. How right or wrong am I? I really need WP/Thesis Iframes and the web is full of only templates with self serving attributions at the bottom of the template. A real distraction to my own goals!
Can you help “us”? I’m sure there are others in the same boat!
Kind regards,
David
kristarella says
David — If you want a page that is just like your site, except has no sidebar and contains an iframe you can just create a regular page with the No Sidebars template applied and paste the iframe code in the post contents. If you want to remove the header and footer as well then you’ll want the code in this post.
You can make the content width narrower on just that page by using the page’s custom body class:
.page-name #content {width:520px; margin:0 auto; float:none}
, or something to that effect.Mike says
Kristarella,
Your help and generosity are an example for everyone in the community. Thank you.
I’ve followed your instructions to create a squeeze page with two sidebars, but -as you said earlier- I’ve been relying on my cut/paste skills, rather than learning how this all works. With that said, I’d like to modify the sidebars’ positions so that they’re lower on the page, and prevent them from taking the custom list item image that I’ve added for this page.
this is the page in question: http://www.pivotalwriting.com/bios/
I want to respect your time, so please feel free to point me to the appropriate lessons, or the coding terminology that I need to learn about.
Gratefully,
Mike
kristarella says
Mike — Sounds like you need just a bit of CSS. Padding to the top of the sidebar perhaps. Have you already figured your issue out? If not let me know and I’ll give you more details.
Mike says
Thanks for your offer, K.
I’m sure it’s a comparatively simple answer. I’m just not finding the advice/how-to that applies.
I think this has taken care of my padding question:
.custom.bios #sidebar_1 {
padding-top: 14em;
background: #ffffff;
}
Now I’d like to add image to this special page’s sidebar (so they’ll appear above and below a sign-up form). More than anything, I’d love to learn the general principle behind manipulating code for a specific page like this.
Again, I want to respect your time, so please feel free to point me to the appropriate lessons, or the coding terminology that I need to learn about.
Gratefully,
Mike
kristarella says
Mike — Take a look at my tutorial for different header images on pages it’s got both the CSS and PHP principles for targeting a particular page. I hope there’s enough info there for you to make it work on areas other than the header. 🙂
Sahil Kotak says
I never knew I can use Thesis as a Squeeze page also, it would be very interesting to test it out. Thanks a lot for this post.
manu says
Can you point out some websites that have implemented this idea? Code is great, but would love to actually see how it looks…Thanks
kristarella says
Manu — I’m not sure who’s using it and how. I’ve used the idea on a few sites to change the sidebars around etc, but it doesn’t make the page look terribly different. Got a site coming out soon that uses it heavily for the front page, but it’s not live yet.
Vijay Sharma says
Thanks for the great article. Thesis theme has so much to learn.
Zack Shorten says
Hi Kristarella,
I recently had to restore some old files and repair some errors here and there slowly. I have one that I am not sure about and was wondering if I could see what you think. I get the following error at the bottom of every post and Im not sure exactly whats causing it. All pages seem fine, only posts are giving me an issue.
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, ‘readmore’ was given in /public_html/wp-includes/plugin.php on line 405
Grateful for any help.
-Zack
kristarella says
Zack — Try searching your custom functions file for “readmore”. I think there is probably an add_action, or add_filter function somewhere that has “readmore” where it should actually have a function name.
Cory says
I am trying to get my sidebar to move up on the page. Currently it is below the comments and I want it where it where it should be at.
Thanks for all your help.
Cory
kristarella says
Cory — Is it fixed? If not, which browser? The URL you gave in the comment details?
Cory says
Kristarella,
Sorry, my website it http://somanytooreview.com
Thanks,
Cory
kristarella says
Cory — It’s because on the single pages the sidebar is not inside the div “content-sidebar-wrap”, but I can’t tell you how to fix it… there’s many elements in your site that are not native to Thesis and all the measurements are in pixels, which is not the native Thesis CSS. So, I’m not sure where the root of the problem is.
Nicholas says
Hi Kristrella
Thanks so much for this solution. I just need to know, how would I remove the feature box as well? I can remove the sidebar, the footer, but no matter what I try, the Feature box just sits there…
Thanks!
kristarella says
Nicholas — It depends where the feature box is, but say it’s above the content you can add
remove_action('thesis_hook_before_content', 'thesis_feature_box');
to your group of removal commands.Wendy says
Hi Kristarella and thanks for your great tutorials! I am having a problem with mysteriously disappearing widgets. After placing any widget within one of my newly created sidebars, they disappear upon return to the widgets panel. I have tried the Berchman tutorial as well. His code is similar but I get the same results. I am not new to Thesis but am not a PHP guru either. I am using Thesis version 1.8.2. and have several plugins. I suspect plugins might be conflicting??
I spent a great deal of time yesterday messing with the sidebars and feel like I tried everything to no avail. I am now using the Widget Context plugin and still cannot seem to get where I need to be. Basically, what I want is all pages and posts to have a default sidebar EXCEPT for my menu pages (they are pages and not posts). I do have a .menu-page body class. I think I need to re-focus on a simpler solution. It’s probably been right under my nose all along. Can you point me in the right direction?
Thank you so much for your expertise!
kristarella says
Wendy — I think it’s an issue with the sidebar names & IDs… something weird happens sometimes. I’ve updated the code in the post to change the name to something a bit more similar to what’s in the WordPress Codex, i.e.,
'name' => sprintf(__('Landing Page %d'), $i ),
. Try that and see if it helps.Wendy says
Thank you for the response. I’ll give it a second go. Although I copied the code two or three days ago, maybe I missed something. I want to register just one sidebar. Should anything be modified in the following with only one sidebar?
register_sidebars(2,
array(
‘name’ => sprintf(__(‘Landing Page %d’), $i ),
‘id’ => ‘landing-page-$i’,
‘before_widget’ => ‘<li class="widget %2$s" id="%1$s">’,
‘after_widget’ => ‘</li>’,
‘before_title’ => ‘<h3>’,
‘after_title’ => ‘</h3>’
)
);
Thank you!
Wendy says
Thank you Kristarella,
I think I’ve got it working now. My widget content no longer disappears after modifying the following few lines:
register_sidebars(1,
‘name’ => sprintf(__(‘Lakeside Menu Pages’) ),
<?php thesis_default_widget(‘lsmenu-page’); ?>
My only remaining question is this line:
‘before_widget’ => ‘<li class="widget %2$s" id="%1$s">’,
Poking around a bit on other blogs suggests this line would be the same regardless of whether I register 1 sidebar or 2. Is this correct?
My complete code now looks like so:
function custom_body_classes($classes) {
$classes[] = "lsmenu-page";
return $classes;
}
function custom_remove_defaults($content) {
return false;
}
register_sidebars(1,
array(
‘name’ => sprintf(__(‘Lakeside Menu Pages’) ),
‘id’ => ‘lsmenu-page’,
‘before_widget’ => ‘<li class="widget %2$s" id="%1$s">’,
‘after_widget’ => ‘</li>’,
‘before_title’ => ‘<h3>’,
‘after_title’ => ‘</h3>’
)
);
function lsmenu_page_sidebar() {
?>
</div> <!– custom end #content –>
<div id="sidebars">
<div id="sidebar_1" class="sidebar">
<ul class="sidebar_list">
<?php thesis_default_widget(‘lsmenu-page’); ?>
</ul>
</div>
</div>
<div> <!– balance out #content divs –>
<?php
}
function apply_custom_filters() {
global $wp_query;
$lsmenu = get_post_meta($wp_query->post->ID, ‘lsmenu-page’, true);
if ($lsmenu) {
// remove unwanted sections
//add_filter(‘thesis_show_header’, ‘custom_remove_defaults’);
add_filter(‘thesis_show_sidebars’, ‘custom_remove_defaults’);
//add_filter(‘thesis_show_footer’, ‘custom_remove_defaults’);
//add custom body class
add_filter(‘thesis_body_classes’,’custom_body_classes’);
// add new sidebars
add_action(‘thesis_hook_after_content’,’lsmenu_page_sidebar’);
}
}
add_action(‘template_redirect’,’apply_custom_filters’);
kristarella says
Wendy — I corrected the code in the post just yesterday…
Yes, the before & after widget & title lines remain the same regardless of how many sidebars you’re registering.
Wendy says
All is good. Thank you Kristarella!
J. Fernando Garcia says
Kristarella writes:
The second function selects the page on which to apply the filter and then applies the filter to the header, sidebars and footer, just before Thesis loads on that page. Change “Squeeze Page” in if (is_page(‘Squeeze Page’)) to the title of your squeeze page. If you want to filter multiple pages you can add their names as an array. E.g., if (is_page(array(‘Squeeze Page’,’Second Squeeze Page,’Magical Landing Page’))).
My Comment:
I’m not a code guru, but I think you are missing one ( ‘ ) right after “Second Squeeze Page” and before the ( , ) in the last line of this paragraph.
kristarella says
J. Fernando Garcia — You’re right; I’ve fixed it.
keshav says
hatsoff mam!!!!!!!!!!!!
awsm posts u have………..
Robert Schrader says
My landing page is right here:
http://leaveyourdailyhell.com/subscribe/
How do I remove the Facebook boxes and the Google + thing?
Thanks so much! I love your site!
kristarella says
Robert — Did you still need an answer on this? If so, not sure which ones you mean.
Nikhil Goyal says
Thanks for the great tutorial. Just beginning to wet my feet in thesis. Do you have any suggestions on how to create landing pages that offer users downloadable content on another page say a Thank You Page
kristarella says
Nikhil — Your best bet is probably to use a plugin for that. Most shop plugins enable a thank you page. It is possible to do it with a form and a bit of custom PHP, but unless you’re familiar with PHP or willing to spend the time on it, it’s probably a bit too involved.
Unclebob says
Great Post Kristarella I am not a programmer but you explain this is a logical way that even I can follow. Does this code apply to posts as well or do we need more code to do this?
kristarella says
Bob — You can use this on posts if you want, but if you’re using the first code block you need to change
is_page('Squeeze Page')
tois_single(ID)
. I can’t really think of a reason you would want to use a post rather than a page though, the URL for posts are longer than pages and in Thesis pages have most of the capabilities of posts.Gary says
I’ve tried all three codes from the article, starting with the landing page options and then both squeeze page options. Something about the copy and paste is breaking my custom_functions.php file. I’ve looked to see if there are things missing, but don’t see them. Also, the code is place in the middle of the file not at the end; therefore I don’t think random spaces are causing it.
I do have a custom footer and use a custom full width header (I believe the full width header code was from your blog?), is it possible that that causes some error? Doesn’t make sense, but just a thought of possibility?
I have also tried through the custom file editor and ftp to see if something odd is happening through the editor, still no luck. As soon as I remove the code, everything works.
Gary says
I thought I would share what I found. I had a custom page designed for me about 1.5 years ago, after looking through their code they had already inserted this code:
function custom_remove_defaults($content) {
return false;
}
That was causing the file to break, after I removed the second instance (from the code I was copy and pasting from here) it worked perfectly. Thanks.
kristarella says
Gary — Thanks for letting us know what happened. Yes, you can’t have 2 functions declared with the same name and I do tend to be consistent with the way I name my functions, which means if you join 2 tutorials that might be something to look out for… Maybe I should make a FAQ page or something like that where I can address that issue.
What you can do when something like this happens is set WP_DEBUG from false to true in wp-config.php, which should allow you to see the specific error message that’s causing a blank site. Make sure to turn it back when you’re done.
Dankobert says
Hi Kristen,
THANK YOU!! Great tutorial even for me as a starter in thesis (first month – wish me luck 😉
I’ve tried all three examples from this post, they all worked great.
I now wonder how to make the markup for differnet arrangements..
such as
sidebar | content | sidebar and
content | sidebar | sidebar.
Nobody asked this in 145 comments, although you asked for it. Any suggustions onthis?
THX again for your great help,
Dankobert
kristarella says
Dankobert — To make different page template layouts you will need to set a different custom field for each one… it would probably be easiest to use the same custom field name with different values, e.g., field name = “layout”, field values = “s1contents2”, “contents1s2”. Then you’d use the code I already showed for adding different sidebars, but you’d change the last function to something like
Then you also need to add the other functions I’ve inserted there for the second layout…
NB I haven’t tested this code, but it should be okay. Also, I’m using new hooks in there:
thesis_hook_content_box_bottom
and top… These are new since I wrote this tutorial, and simplify things slightly.Dankobert says
KRISTARELLA, thanks so much for that. I’ll report.
THX again for all your great help,
Dankobert
Fulya says
Hi Kristarella,
Your tutorials are really informative I really appreciate all the effort you put on your job.
I already posted this question to the thesis Forum but unfortunately couldn’t get an answer from them.
My problem is
I created couple of thesis theme 1.8.4 with Custom Template Pages.
Then I uploaded Product Skin Custom folder.
I created a Front Page I am fine with creating Front Pages.
So far so good.
But after I uploaded Product Skin as well my other Custom Template Pages look strange
http://www.loveyourbodyforever.com on the front page when I scroll down there is a huge gap How Can I prevent This?
http://www.loveyourbodyforever.com/welcome to my web page
http://www.oveyourbodyforever.com/my-products
It Shows Header strange why not showing properly?
pages looks strange looks content inside the box but i don’t want my contents to show inside the box because these pages contents NOT a post. how can I prevent this ?
Also on the main front page when I scroll down there is a huge gap how can I prevent this happening?
I would like to use my other pages ( apart from Front Page ) like Custom Template how can I manage to do this? Thanks for the reply.
Kindest
Blogging Tips says
I will try this code on my blog to make a impressive landing page !!
Mike says
Hi, I don’t know where to find the “custom fields” area in order to enter “squeeze-page” to use the code you supplied. Is it on the “Edit Page” somewhere? I’m using Thesis 1.8.4 and I don’t see it.
In other news, I tried using the following code using the page number instead of a page title, and that seemed to work…
function custom_remove_defaults($content) {
return false;
}
function apply_custom_filters() {
if (is_page (‘2’)) {
add_filter(‘thesis_show_header’, ‘custom_remove_defaults’);
add_filter(‘thesis_show_sidebars’, ‘custom_remove_defaults’);
add_filter(‘thesis_show_footer’, ‘custom_remove_defaults’);
}
}
However, when I tried it using the “array” line you suggested, and multiple page numbers instead of titles, it didn’t work. I’m not sure what I’m doing wrong.
Sorry, total newbie here!
kristarella says
Mike — Yes, the custom fields are on the edit page, but they might have been turned off from view in a recent version of WordPress, to show them again go to the top of your edit screen where there is a tab called Screen Options and then select to show the custom fields, then that box will be near the bottom of your edit page.
I don’t know why your page ID array wouldn’t work. Try comparing your code to the Conditional Tags reference and see if you’ve made a mistake anywhere.
Mike says
Thanks Kristen! I was able to show the “custom fields,” add the name and it worked perfectly! Gosh, it’s amazing how much time you can save once you learn some simple things!
There’s still quite a bit of space left at the top of the page – where it shows the page title. Is there a tutorial on how to remove that, instead of just deleting the name on the edit page?
This is fun! I feel like I’m talking to a celebrity! Thanks again for your help!
kristarella says
Mike — I’m not sure what exactly is causing the white space without viewing the page, but you can use Firebug or Webkit Inspector to find that out, and then edit your custom.css file to counter it. I have a video about firebug and Webkit Inspector (in Chrome and Safari) works in a similar way.
kristarella says
Fulya — Sorry, but I don’t really understand any of your issues. It might be a language barrier, or you may have changed the pages since you posted your questions. I have a post: how to use firebug that might help you figure out any gaps that need to be corrected via CSS… you have multiple empty paragraphs in the home page that can probably be removed in the editor, apart from that the other pages don’t have anything on them and I don’t really know what you’re referring to with the Product Skin Custom folder.
Brian says
I have the same situation as Byron Coke above (#8). I successfully used your solution in your reply (#9) to “filter the headline area” successfully on “POSTS” (via – “asides” category). Thank you!!
However…as PAGES have no “category” I was NOT able to determine (where) & (what) code to use to eliminate TITLES on PAGES. I tried “unsuccessfully” to utilize the (CSS Class) field under the META Data on the EDIT PAGE.
Question – (where) & (what) to Eliminate page titles. Thanks Brian
kristarella says
Brian — You can view the Conditional Tag documentation for all the tags that WordPress uses to determine page type.
In terms of the headline filter example, you would change it to
if (in_category('asides') || is_page())
to remove headlines in the asides category and on all pages. The double pipe, ||, means “or”, so it says “if post is in category “asides”, or this is a page (rather than a post or archive page) do the following”.Brian says
Kristarella, thanks for your really quick reply…Fixed…Yippee!
Took me a bit to add it to beginning and ‘end’, but all set… Thanks again! Brian
BTW…pretty name 🙂