andymacdonalduk
Forum Replies Created
-
Ahh I totally understand now. After modifying my code by using the example at the link you sent me, my random post section now appears to be working perfectly.
Thanks very much for your advice (and time) Alchymyth!!
Hey there,
I think the reason there is little randomness there right now is there is only three blog posts on the site – it was only launched today. I use the same code on another of my sites, and it excludes the said categories correctly and all seems to be perfect with that.
Here is the exact code im using right now:
<span class="wpn_heading2">Random Gallery <a class="wpn_toggle-expand wpn_toggle-hide" href="#"></a></span> <div class="wpn_box wpn_expandable" style="text-align:center; padding-top:10px; padding-bottom:5px;"> <div style="width:260px; margin-left:18px;"> <?php $rand_posts = get_posts('numberposts=1&cat=9,-10,-1,-3&orderby=rand');?> <a href="<?php the_permalink(); ?>"><?php $thumb = get_post_meta($post->ID, "wppt_preset1", true); if($thumb) echo ' <img style="border:3px solid #393939;" src="'.$thumb.'" alt="<?php the_title(); ?>" />'; ?></a> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> </div></div> <div class="wpn_box-bottom"></div>
Hi Esmi,
I looked into that get_children thing you linked me to, and I genuinely don’t understand a word of it, or how I can put it to use to give me the result I am looking for.
Any chance you could give me a basic idea of what I need please? All I want to do is put a box in my sidebar, and display a video from a random post in the ‘Videos’ category of my site.
Any help or advice you give me will be very much appreciated. Thanks for your time.
Andrew.
Forum: Fixing WordPress
In reply to: Can an If Statement Work In the WordPress Header?Yes, it would be interesting to know what the problem was, but in this case, I now have it working with the php includes, so im happy.
Thanks again sir. ??
Forum: Fixing WordPress
In reply to: Can an If Statement Work In the WordPress Header?Yeah it’s good to know that you can use if statements outside the loop, i didn’t know that.
I tried the code above with the global&post; as you mentioned, and the same thing happened, it continued to show up. But Im going to do what I mentioned in my previous post (before you left yours).
Ill stick the ad code in a php file and call it from every page I need it to show up on. That way I can not call it from the image.php file and it wont show up. That seems like the easiest and quickest way to get the job done.
Forum: Fixing WordPress
In reply to: Can an If Statement Work In the WordPress Header?What Im going to do Voodoo (don’t know your real name), is instead of including the adsense in the header, Ill just stick it inside a php file, and call it from within all of the template pages with a php include.
That way, I can omit the code from the image.php by not calling that specific file. It seems like the easiest and quickest work around, and it’ll do the exact same job, so ill do that instead.
Thanks very much for your help and advice though!!
Forum: Fixing WordPress
In reply to: Can an If Statement Work In the WordPress Header?Hey no worries, I appreciate that there is somebody out there who is willing to help me, and even-more-so that like me, your also not an expert at it.
I used the code you gave me, and again, it hasn’t made a difference. I have no idea why it wouldn’t be working because from the looks of it, its just a standard if statement – I have exactly the same code on other parts of my site which work perfectly.
The only thing I can think of is that the header is not within the loop is it? Do If statements work outside of the loop? Im not sure?
Forum: Fixing WordPress
In reply to: Can an If Statement Work In the WordPress Header?Can anybody help me with this please?
Forum: Fixing WordPress
In reply to: Can an If Statement Work In the WordPress Header?Hey there,
If that’s the case, I must apologise for getting it wrong, however I have added the code to my header.php file, and it doesn’t seem to have done anything. The ads are still showing up on every page of the website, including when the image.php file is being used.
Here is the code Im using…
<?php if (!is_page_template('image.php')) {?> <div style="background:#F4F9F9; border:solid; border-width:1px; border-color:#A5A5A5;text-align:center;padding:10px; margin-bottom:15px;-moz-border-radius-:3px; -webkit-border-radius: 3px;"> <script type="text/javascript"><!-- google_ad_client = "pub-9907904751335716"; /* 728x90, created 7/4/10 */ google_ad_slot = "3185972388"; google_ad_width = 728; google_ad_height = 90; //--> </script> <script type="text/javascript" src="https://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div> <?php }?>
Have I done anything wrong? Just incase you need to look at the site in question, its https://www.purebeyonce.com
You can go to this link, which will show you the image.php template in-use. As you can see, the leaderboard adsense block is still displayed along the top of the page, despite the if statement being placed in the header (inside the wrapper div).
https://purebeyonce.com/beyonce-knowles-dangerously-in-love-photoshoot/beyonce-knowles-01-580×796
Forum: Fixing WordPress
In reply to: Can an If Statement Work In the WordPress Header?Hey there,
I havent actually tried it yet, but on first site, does that code only include ads on the image.php page?
What I am looking for is the ads to be on every single page of the site, except the image.php template… if that makes sense?
Forum: Fixing WordPress
In reply to: Using Without The Image Displaying?Ah, that did the job perfectly. Thank you very much sir.
Forum: Fixing WordPress
In reply to: How Can I Use WP_Query to Display Posts from Only ONE Category?Esmi, I have a question, if you don’t mind?
You know you showed me how to have four of the latest posts from my ‘Gallery’ category show up in a four-column section of my home page?
Is there a way to do exactly the same thing, but output categories instead? I have individual categories inside my gallery, but I want to create a gallery page which is specifically designed to be the ‘springboard’ to push people to those individual gallery categories.
So for example. When somebody clicks on a gallery page, I want a page to be displayed which shows a list of categories inside the ‘gallery’ category. Maybe the icon for each category could be the latest picture added in the latest post inside that specific category.
Does that make sense, and is anything like that possible?
Forum: Fixing WordPress
In reply to: Can an If Statement Work in a Sidebar??Ahh, that worked a treat. Thank you very much. Your advice is appreciated. ??
Forum: Fixing WordPress
In reply to: How Can I Use WP_Query to Display Posts from Only ONE Category?Esmi, please ignore my last post.
I have worked out the CSS layout and now have it working perfectly. Thanks again for your amazing help!! I really appreciate it.
Forum: Fixing WordPress
In reply to: How Can I Use WP_Query to Display Posts from Only ONE Category?Hey there Esmi,
That did the trick perfectly, thank you very much! Are you able to give me a rough Idea of what exactly was done there please?
You mentioned Id have to re-do my CSS which isn’t a problem, but are you able to point me in the right direction on where roughly I need to be looking please?
I guess what Im asking, is what has actually changed in the above code, which would mess up the css layout of the featured gallery, so I know where I should start looking so I can fix the changes?
Thanks again. ??