Jump to content
Sign in to follow this  
toasthosting

Am I doing something wrong? Adding action to functions.php brings site down

Recommended Posts

toasthosting

Hi, I am a new PageLines user; I'm fairly experienced with PHP, but I've got a simple problem that I know has a simple answer, I just need a push getting there. I can't add any actions to my functions.php - I've tried doing it in the child theme and the main functions.php just to be sure. When I say I can't add any functions, I mean *any*. So if I do this: add_action('pagelines_before_theloop', 'do_nothing_at_all'); function do_nothing_at_all() { echo 'I am doing nothing'; } and I reload my page, it's a blank screen. I've pasted in example functions from other people - such as, increasing the posts displayed on is_home() - nothing works. I know this is a simple issue. What am I doing wrong? This is the sort of function I'm aiming at, from a PageLines forum: add_action ('pagelines_before_theloop','only_articles'); function only_articles(){ if (is_home()) query_posts('cat=-6, -5&posts_per_page=9');}

Share this post


Link to post
Share on other sites
Simon
post the 'broken' functions.php to pastie.org

Share this post


Link to post
Share on other sites
toasthosting
Hi pross. Here it is - http://pastie.org/3428480 You'll see that it literally has that "almost nothing". I also did try it in the child theme's function.php as well, with the same result. I did the usual diagnostics - pared it back until there wasn't even anything in the function. But still it falls over.

Share this post


Link to post
Share on other sites
Simon
where is this code located?

Share this post


Link to post
Share on other sites
toasthosting
It's in wp-content/themes/pagelines/functions.php

Share this post


Link to post
Share on other sites
Simon
You shouldn't edit the theme core files. Install the customize plugin, it contains a style.css and a functions.php for this purpose.

Share this post


Link to post
Share on other sites
toasthosting
Damn, I seem to have issues with FF/OS X and posting on here. It ate my post (not the first time it's happened), and then when I reloaded the page, it came up with a saved draft from yesterday. Anyway: Hi again Pross, thank you again for your help. I wouldn't normally have even tried to add code to the core - I tend to learn best by actually screwing things up and then working out how to fix them (just a quirk of my brain). I had misunderstood some advice from others - namely, to put the code into the child theme's function.php - but when I did the code above, it also took my site down. I've now taken your advice and installed your plugin and the code doesn't take my site down :) But, when I put the code I actually wanted, it has no effect. add_action('pagelines_before_theloop', 'different_post_count'); function different_post_count(){ if (is_home()) { query_posts( 'posts_per_page=5' ); } } My WP settings call for posts per page of 30 (so I can clearly see the difference while I test), but I still get 30 on my home page. I know this is now not the question I originally asked; if it's a simple error I'm making and you can help, I'd really appreciate it. Otherwise I'll start a new thread so people can follow it more easily. Thanks again.

Share this post


Link to post
Share on other sites
toasthosting
Oh, also - obviously, as you've answered my original question (thank you again :) ), should I click "accept" now, or will it close the thread?

Share this post


Link to post
Share on other sites
catrina
If you thank pross for answering your question, the thread will be considered "Answered" but it doesn't completely close it. You can start a new thread for the new issue, though.

Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
toasthosting
Thanks Catrina, I've done that and I'll start a new thread if I still can't work it out (I *know* it's something simple I need to do!)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×