Jump to content

Hopeful

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by Hopeful

  1. Hello, I am looking to randomize contents of a .txt document. I found a code that I think might work, but how can I alter it so it works with what I'm looking to do? $f_contents = file("TheRandomContent.txt");print_r($f_contents);//$line = $f_contents[array_rand($f_contents)];//echo $line; First off, is this the code I'd want to use? Secondly, if my .txt file is located in say following place, how can alter the above code to call the text of the document located there? http://TheWebSite.com/wp-content/uploads/TheRandomContent.txt I am familiar with the following code, but I just don't know how to incorporate it with the above code: <src="http://TheWebSite.com/wp-content/uploads/TheRandomContent.txt" Am I on the right track here? And, if so, how can I incorporate this in to the first code I listed? Thanks in advance for your help!
  2. Thank-you for the suggestion, but I was unable to get that to work as well. That said, I have found what I believe to be the answer through the graciousness of a different source, and I'll share it here for anyone else who may be looking for this information. I needed to log in to my hosting company's CPanel, use the file manager, and drill down to my theme's .php files. I copied my sidebar.php file, and created a new one with the naming convention of sidebar-newname.php. It needs to be all lowercase and one word.This created a new .php file in my WordPress editor. Next, I went in to my functions.php file to create a new sidebar for me to drag widgets in to. I did this by inputting the following: 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>',)); Sidebar_2 is what I named it here in this example, and you can replace that with whatever you want to name it.Please note that this code is a bit different than the above code, and it eliminates the 'li' parts, and therefore eliminates the bullet point issue I was experiencing before.The difference here is that I removed the 'li' before the id part, and then I replaced the after widget line with the br code to give each sidebar piece a space between them. After this, I went to my page.php file, and inputted 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('sidebar'3); ?> <?php else : ?> <?php get_sidebar(); ?> <?php endif; ?></div><?php get_footer(); ?> Please note that the code is repeated here.The sidebar2 is what I named my new .php file. I use only what comes after the sidebar- part. So, if you compare it to the above explanation, you would put newname there instead of sidebar2.The 2 is page id 2.What it seems to be saying is that whatever is in sidebar2, put it on page id 2, or if there's nothing in sidebar2, then get whatever is in the sidebar.php file. I also needed to open my newly created sidebar2 php file, and edit one piece of code like so: <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar_2') ) : else : ?> The only part I changed there was the Sidebar_2 part. Next, I just needed to drag what I wanted for widgets in to the appropriate sidebars. I have done some preliminary testing with this, and it seems to be working in just the way I've been looking for it to work. I hope that makes sense, and thanks everyone for your time!
  3. Thank-you for the li code information. I'll give that a try and see if that affects styling or not; hopefully not. And, I don't doubt that I've not done it right since I don't know enough about this yet.Here is the same code I used above, only altered as I mentioned a couple posts back. I wanted these pieces excluded from pg id's 1 and 2. When I duplicated the page id's here, it excluded both from only page 1, and did not exclude anything on page 2. In order for this to work for me, I would need it to somehow exclude a lot on those pages, and this would be duplicated for many pages of the site so that way I can drill down what pieces go with which pages as they will all be different. div id="sidebar-center"><?php if (!is_page('1,2') && dynamic_sidebar('Sidebar_Right_2') ) : else : ?> <?php endif; ?> </div> <div id="sidebar-center"><?php if (!is_page('1,2') && dynamic_sidebar('Sidebar_right') ) : else : ?> <?php endif; ?> </div> Is there something about this code that has the potential to work, or do I need to try something else altogether?
  4. Thank-you for the information. I am using a theme. Is there something in that above code itself that could be altered? Also, as much as I thought the above was basically my answer, it's unfortunately got a downfall for what I'm looking to do. Since that works off of excluding pages, then that means I would need to repeat a lot of the same page id#'s over and over again. As soon as I tested that out by putting page id's 1 and 2 in both places, then only page id 1 gets excluded, and nothing gets excluded on page id 2. Again, I'm a real newbie. I'm OK with copying and applying examples, but beyond that I don't yet know much. Thank-you everyone!
  5. Well, I can't say as though I completely understand everything you are saying, but through research, I think I may have found something that might work. But, maybe there's an easier way? And, I still have a question about it (which I'll ask below). I found this code in my Theme Functions editor: ));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>',)); What I did was copy all that one row down, and then changed 'Sidebar_right' to 'Sidebar_Right_2', which added a new place for me to put widgets in to. Then, I took another code I found through other research and applied to my sidebar editor area: <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> If I just keep repeating that code, and input the page id's of all pages I want to exclude, and then put the widgets I want in to the appropriate places that I created with the first above code in my widgets area, then I think this will work (though it will be a lot of work to exclude all the pages for each one). My question with this is there are black dots appearing next to every item on the sidebar. Is there maybe a list code somewhere that's causing that? It looks like bullet points.
  6. Where would I add that? Sorry, I'm quite the newbie. I also found the following code in my functions editor. Maybe this gets altered in some way instead? 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>',
  7. Hello, I am looking to customize by right sidebar for my WordPress website, and am wondering if there is a fairly easy way to do so with php code. I don't know all that much about code, but I have customized other codes on my site with good results. I am aware there is a custom sidebars plugin, but I'm trying to not depend upon plugins too much. And, I'm not sure if it has a way for me to do what I am looking to do or not either. There are certain pieces of my right sidebar that I am looking to have displayed on all of the pages of my site. This happens automatically by default. However, I am also looking for other pieces of my right sidebar to appear only on specific pages. Basically, I'm looking to have things that appear on every page and things that appear only on certain pages there simultaneously. 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?Is there maybe a way to exclude something from appearing on certain pages by using page ID#'s or something? Then, if there were no excluded pages, whatever code I have would appear on every page? <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar_Right') ) : else : ?> Does anyone know how this can be accomplished? And how I could tell the code to place things where I want them placed on the sidebar? Thanks in advance for your help!
×
×
  • Create New...