HopefulGJL
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Custom sidebar for each page of an archive or category?Maybe there’s something I need to do with it then as I so far haven’t been able to get that to work.
I’m assuming this goes in to my archives php file?
Or, should it go elsewhere?For this url: website.com/category/communication/page/4, I have so far tried this:
<?php if (is_category('category/communication/page/4')) : ?> <?php get_sidebar('custom_sidebar'); ?> <?php else : ?> <?php get_sidebar(); ?> <?php endif; ?>
And
<?php if (is_category('article-slug-100')) : ?> <?php get_sidebar('custom_sidebar'); ?> <?php else : ?> <?php get_sidebar(); ?> <?php endif; ?>
But, those aren’t working for website.com/category/communication/page/4.
Would you happen to know how it can be altered so that it does work?
Thanks!
Forum: Fixing WordPress
In reply to: Custom sidebar for each page of an archive or category?Thank-you for the quick reply. I am aware of that Codex page, but perhaps you can let me know what on that Codex page might work?
Please note what I’ve already tried from that Codex page from the above information.
Thanks!
Forum: Themes and Templates
In reply to: Code for Custom SidebarsI have discovered something else to add to this information. If you want to call the same sidebar for more than 1 page, then you can use this:
<?php if (is_page('1'||'2'||'3'||'4'||'5'||'6'||'7')) : ?> <?php get_sidebar('sidebar1'); ?> <?php else : ?> <?php get_sidebar(); ?> <?php endif; ?>
With this, page id#’s 1,2,3, etc. are all calling and using sidebar1.
If you want to specify posts instead of pages, then please read my post here.
I’ve got it!
<?php if (is_single('100')) : ?> <?php get_sidebar('homepage'); ?> <?php else : ?> <?php get_sidebar(); ?> <?php endif; ?>
Just change the is_page with the is_single and then put the is_page in to your page php file while putting the is_single in to your single (single post) php file where the code otherwise calls for the sidebar(s).
If you want more information on how to accomplish this, please read my last post here.
I also found more information here.
And, it looks like that codex article I linked to explains how to do the categories.
Thank-you!
That does look interesting, thanks for that information.
That said, it looks like she’s trying to pull post information in to her sidebar.
I am looking to input something unique that I put in to the sidebar of the posts instead.
So, if it’s post 1, then I want to display A on the sidebar.
If it’s post 2, then I want to display B on the sidebar
If it’s category 3, then I want to display C on the sidebar, etc.(By unique, I mean A, B and C is code that I have from outside of my site itself; like code to link to other sites or merchandise to buy that is customized to that specific page, etc.)
I’m not sure that the description of what her code is doing will work for what I’m looking to do?
I really hope to find the code, otherwise I guess I’m going to take all of my posts, make them in to pages instead, and never use posts or categories since I know my method works to customize pages. It just means redoing a whole ton of links.
I hope I don’t have to do that?
(Please note I’m looking to avoid using plug-ins – I have my reasons.)Thanks!
Forum: Themes and Templates
In reply to: Code for Custom SidebarsDavid: Thank-you so very, very much! That is what is working.
So that anyone else reading this can hopefully understand what I did, I offer the below explanation:
I logged in to my hosting company’s CPanel, used the file manager, drilled down to my theme’s .php files, and copied + added new .php files as explained above by David.
Then, I created the new sidebars I wanted in my functions.php file with the following code (like this example):
if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Sidebar_2', 'before_widget' => '<id="%1$s" class="widget %2$s">', 'after_widget' => '<br />', 'before_title' => '<h2>', 'after_title' => '</h2>', ));
Please note this code is a bit different than what I posted above. I removed the ‘li’ before the id, and for the after widget part, I replaced the ‘/li’ part with the br part so that my sidebar pieces will no longer have bullet points next to them and each piece will have a space between.
Next, I went to my new sidebar.php file that I created in my CPanel file manager, and changed the code to:
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar_2') ) : else : ?>
(The Sidebar_2 is what changed here.)
After that, I needed to go to my page.php file, and add the following:
<?php if (is_page('2')) : ?> <?php get_sidebar('sidebar2'); ?> <?php else : ?> <?php get_sidebar(); ?> <?php endif; ?> <?php if (is_page('3')) : ?> <?php get_sidebar('sidebar3'); ?> <?php else : ?> <?php get_sidebar(); ?> <?php endif; ?> </div> <?php get_footer(); ?>
Please note that the code is repeated there with the different page id numbers, and that the different sidebar.php files are being called in each.
From what I have seen so far with tests is that it seems to be saying that what I want on page id 3 is contained in sidebar3, etc.After this, I inputted my widgets in to the appropriate sidebar, and it all seems to be working just as I’m looking for so far.
I hope that makes sense to anyone else who is also trying to figure this out. Thanks everyone!
Forum: Themes and Templates
In reply to: Code for Custom SidebarsThanks for providing more ideas.
I tried the class part in to what I had, and it didn’t seem to make a difference.
Also, if I put in page id#’s 1 and 2 for both lines of the code in what I had above, then things get excluded only on page id 1, and nothing on page id 2.
This seems so close, but I’ll need to be able to constantly repeat a lot of the same page id’s to exclude them to use this, and it’s not allowing me to do so.I did try various things with the different code you provided, but I for whatever reason am unable to get it to work. I’m not sure what I’m missing.
And, I think the bullet points I mentioned above are coming from that ‘li’ code, so I’m not sure what could be altered there to eliminate those bullet points either.
David: I’ll take a look in to what you’ve provided information on too, thanks!
Forum: Themes and Templates
In reply to: Code for Custom SidebarsOh, thank-you for catching that. I think I might know what you mean.
If I take the first
(!is_page('1')
and change it to(!is_page('1,2')
while leaving the second one as(!is_page('2')
, it’s not excluding the first one from page id#2.It feels like I’m getting really close to the answer, though.
How do I make the classes you mentioned?
Forum: Themes and Templates
In reply to: Code for Custom SidebarsViola!
I think I have some code that will work. I won’t say it’s the most efficient, but it looks like a combination of what you provided along with something else I discovered is what will work.
In my theme functions editor, I found some code that where I was able to create a new sidebar where I can put the widgets in to. I found:
)); if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Sidebar_right', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2>', 'after_title' => '</h2>', ));
I just copied that code one row down, and changed ‘Sidebar_right’ to a new name, ‘Sidebar_Right_2.
Then, I went back in to my sidebars editor, and applied the code that you provided as a test (changing ‘Sidebar_right’ to what I named the new one to, ‘Sidebar_Right_2).
This looks like it will work. I’ll just keep adding new sidebar places to drag widgets in to, and I think it’ll work.
What I’m finding that works so far is to enter the following in to my sidebar editor:<div id="sidebar-center"> <?php if (!is_page('1') && dynamic_sidebar('Sidebar_Right_2') ) : else : ?> <?php endif; ?> </div> <div id="sidebar-center"> <?php if (!is_page('2') && dynamic_sidebar('Sidebar_Right') ) : else : ?> <?php endif; ?> </div>
After I add the code in to the sidebar editor area, I can then drag widgets around.
Now, excluding pages will be a lot of work, but I’ll take it since it seems to be the solution! Thank-you very much!
Would anyone happen to have any ideas as to why I’m getting a black dot next to what I add to the sidebar? Could it be that there’s a list code somewhere that’s causing that?
Forum: Themes and Templates
In reply to: Code for Custom SidebarsThank-you again. I can see this is making progress.
This had interesting results. I put the page id# in on a page I wanted to test this with. I then put one code in the widget, and the other code after the : else : part of the above code we last discussed.
The code I put in the sidebar somehow appeared twice on every page (one above, one below) except for the page that I put in the page id# for. On that page, the code I put in after the : else : was there on only that page (hurray!), but then the code that I put in the widget still appeared under that.
Is there possibly code to enter after the : else : that would tell it to exclude this page on page id on only page id 1,2,3 etc?
For example, if there was code to exclude pages, then whatever code I have would appear everywhere except for what I specifically told it to exclude.Is there such a thing?
Forum: Plugins
In reply to: [SEO Ultimate] Exclude PagesHello,
I was searching for a different answer when I ran across your question. I don’t know if this is what you’re looking for a or not, and I don’t know what the SEO plugin did/did not do for you, but this is the code that I use to exclude my pages. It’s in my header editor:
<?php echo preg_replace('@\<li([^>]*)>\<a([^>]*)>(.*?)\<\/a>@i', '<li$1><a$2><span>$3</span></a>', wp_list_pages('echo=0&orderby=name&exclude=1,2,3&title_li=&depth=1')); ?>"
Just replace ‘1,2,3’ with whatever the page ID#’s are.
I hope that helps.
Forum: Themes and Templates
In reply to: Code for Custom SidebarsThank-you for the information. I have now tried to use the code from the page you provided a link to. However, I think that one reason it may not be working is because it says that there needs to be something specific done if there is a theme involved. I do have a theme.
The widget-logic visual plugin might be what I end up going with, but I do want to try and find the correct code if possible. That plugin looks perfect if I cannot get the code right. Thank-you for that.
What I know works, at least to put something on all of my pages, is to enter whatever I want my code to be in a widget.
In my sidebar page in the editor, I currently have the following code. It was there originally. It’s just one part of the overall code that is there. Is there something I can put after this code to indicate I want “a” on only page “a” and “b” on only page “b” and “c” on every page, etc?
<div id="sidebar-right"> <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar_Right') ) : else : ?>
Forum: Fixing WordPress
In reply to: How do I delete the admin account?Thank-you so very much for all of the information!
As far as the site is concerned, I had my hosting company delete the entire site and then restore it to a back-up I had months before the issue appeared.
I do, thankfully, regularly make back-ups.
I’ll read over the info you’ve provided here, but I’m pretty certain that it should be OK now because of the deletion and restoration activities.And, I have just realized why I wasn’t seeing a delete option for the default admin account. It’s always the simple things we miss, isn’t it? I (obviously) needed to log out of that default admin account and then log in to my newly created admin account with the unique user name. Then, I was able to delete the default admin account.
Thanks again!
Forum: Fixing WordPress
In reply to: I think I was hacked?Thank-you both very, very much.
My hosting company scanned my site for me at no charge and didn’t find anything malicious. I did have them delete everything and then restore it all from my backup (which was also no cost) just to be on the safe side. It has gone back to long before (months before) that unidentified user was present.
I also did uncheck ‘anyone can subscribe’ as suggested, and every new user is, by default, at the subscriber level.
The only piece of this I do not have resolved is how to delete the admin account. There is no option to delete that currently. Since that is sort-of a separate topic, I will start a new thread if I do not find the answer through searches first.
Thank-you both so much for your valuable information.
Forum: Fixing WordPress
In reply to: I think I was hacked?Thank-you very kindly for your information.
Would having my hosting company delete everything and then restore everything from a back-up prior to that user being there be sufficient?