brownca
Forum Replies Created
-
Forum: Themes and Templates
In reply to: [nano blogger] Change to only 1 widget areaOk i figured this out myself. I created a child theme and added a file called style.css with the code
/* Theme Name: Nano Blogger Child Template: nano-blogger Version: 1.0.0 */ @import url("../nano-blogger/style.css"); /* =Theme customisation starts here -------------------------------------------------------------- */ #container { width: 780px; }and a file called functions.php with the code
<?php function remove_some_widgets(){ unregister_sidebar( 'primary_widget_area' ); //unregister_sidebar( 'secondary_widget_area' ); } add_action( 'init', 'remove_some_widgets', 11 ); ?>and that’s worked.
Forum: Themes and Templates
In reply to: Problems with using variables in phpBrilliant. Thanks very much, I’ll download a proper editor now to avoid mistakes like these in the future. Many thanks.
Forum: Themes and Templates
In reply to: Problems with using variables in phpWell, I’ve found a workaround for now by using an If statement for every single category, which makes for tons more code but it gets the job done. If anyone knows what I was doing wrong before with the variable I’d love to know.
Thanks for your help MichaelH 🙂
Forum: Themes and Templates
In reply to: Problems with using variables in phpThat part of the code isn’t the problem. I’ve already successfully stored the parent category ID, which I know because I checked with:
<?php echo $parent_id; ?>
When I’m viewing a post with category parent id 3, I will see the number 3 in the sidebar, so I know the variable should contain the number 3.The problem is this line:
$my_query = new WP_Query('cat=$parent_id&order=desc&showposts=7'); ?>
specifically the cat=$parent_id part. This doesn’t seem to be looking inside the variable $parent_id for the number 3, because it just returns posts from all categories. When I replace $parent_id with the number 3, the code works. But it shouldn’t make any difference, if you see what I mean?Forum: Themes and Templates
In reply to: Problems with using variables in phpThat doesn’t make any difference – the only difference that should make is getting the category id instead of the parent category id. Unfortunately it does neither, and just returns all posts regardless of category.
I’m pretty sure it’s something to do with using a $variable in line 9 of my code above, since if I replace the variable after ” ‘cat= ” with a number of a category, the code works fine.
I just don’t know why it won’t work with a variable containing a value, but it will work with the value on its own.