If page_content() != '' echo ... possible? (conditional by content) - Printable Version +- GetSimple Support Forum (http://get-simple.info/forums) +-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3) +--- Forum: General Questions and Problems (http://get-simple.info/forums/forumdisplay.php?fid=16) +--- Thread: If page_content() != '' echo ... possible? (conditional by content) (/showthread.php?tid=2826) |
If page_content() != '' echo ... possible? (conditional by content) - ChriS - 2012-02-29 I'm searching again for a php code to use in a template file. I want to check if the content is empty (no content). Example: Code: <?php if (page_content() != '') { ?> Thank you for helping again... EDIT: I think I got it: "returnPageContent(return_page_slug())" is doing the job in v3.1. Maybe it would be helpful to add all the return outputs (if they are short/simple) for the main Template Tags in the Wiki? If page_content() != '' echo ... possible? (conditional by content) - mikeh - 2012-02-29 Add the below function to admin/inc/theme_functions.php or theme/yourtheme/functions.php. It does not matter which one you add it too. Code: function return_page_content() { Then you can use it to return the content instead of echo it. Or You can do the below in your template files: Code: <?php If page_content() != '' echo ... possible? (conditional by content) - ChriS - 2012-02-29 Thank you mikeh! Until now I have no functions.php and prefer to continue with template.php only. But it is nice to have your code here in case I need to use functions.php. If page_content() != '' echo ... possible? (conditional by content) - mikeh - 2012-02-29 ChriS Wrote:Thank you mikeh! Until now I have no functions.php and prefer to continue with template.php only. But it is nice to have your code here in case I need to use functions.php. I revised my post. You do not have to use that function if you do not want to. You can stay within your template file. If page_content() != '' echo ... possible? (conditional by content) - ChriS - 2012-03-01 Thanks for the new piece of code. I have edited my first post at the same time as your first post here. I mean I'm using Code: <?php if (returnPageContent(return_page_slug()) != '') { ?> Does this code have some disadvantage in comparison to yours (I need to output the styling div)? |