![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
So Fucking Banned
Join Date: Jan 2005
Posts: 3,716
|
Need Wordpress Help
I did try searching but can't find the answer.
I am just wanting to make a small change to one of my category pages however I don't have a category.php file Aside from category.php or archive.php where else might I make this change? I have entry.php navigation.php functions.php postinfo.php scripts.php And a few more |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
xXxAffiliateReviews.com
Industry Role:
Join Date: Jun 2007
Location: US
Posts: 1,035
|
What are you wanting to change?
__________________
Available for VA assistance, customer service, sales and support, content writer, etc! Contact: [email protected] |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
So Fucking Banned
Join Date: Jan 2005
Posts: 3,716
|
I am wanting random posts from one category only
Looking to put this code in Code:
query_posts(array( 'showposts' => 6, 'orderby' => 'rand', 'category_name' => 'News' //You can insert any category name )); if (have_posts()) : while (have_posts()) : the_post(); Really I just want to randomise the posts from one category. I would use a pplugin but I can't find one, they all seem to be widgets. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 | |
Monger Cash
Industry Role:
Join Date: Jul 2010
Posts: 2,773
|
Quote:
You would then need to strip out any existing query args from the new category.php file you created, and replace it with something like this: Code:
query_posts($query_string."&showposts=6&orderby=rand") |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
So Fucking Banned
Join Date: Jan 2005
Posts: 3,716
|
I found this in entry.php
Code:
query_posts($args); } ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> Code:
query_posts(array( 'showposts' => 6, 'orderby' => 'rand', 'category_name' => 'news' //You can insert any category name )); } ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
So Fucking Banned
Join Date: Jan 2005
Posts: 3,716
|
Thanks for this vd but there isn't a query args in home.php
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Monger Cash
Industry Role:
Join Date: Jul 2010
Posts: 2,773
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
emperor of my world
Join Date: Aug 2004
Location: nethalands
Posts: 29,903
|
this works for me:
Code:
<?php global $post; $myposts = get_posts('numberposts=6&category=3&orderby=rand'); foreach($myposts as $post) : setup_postdata($post); ?> <?php global $more; $more = 0; ?> <div class="postboxmain" id="post-<?php the_ID(); ?>"> REST OF YOUR POST TEMPLATE HERE </div> <?php endforeach; wp_reset_query(); ?> |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 | |
Monger Cash
Industry Role:
Join Date: Jul 2010
Posts: 2,773
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 |
emperor of my world
Join Date: Aug 2004
Location: nethalands
Posts: 29,903
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 |
Monger Cash
Industry Role:
Join Date: Jul 2010
Posts: 2,773
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 |
Monger Cash
Industry Role:
Join Date: Jul 2010
Posts: 2,773
|
For the OP, here is an example of what one of my category.php files looks like... ignore the html parts of course if you're going to use it:
Code:
<?php get_header(); ?> <div class="large-9 columns"> <header class="site-header" role="banner"> <img src="/assets/img/header/<?php echo rand(1,15) ?>.jpg" /> </header> <?php if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } elseif ( get_query_var('page') ) { $paged = get_query_var('page'); } else { $paged = 1; } query_posts($query_string."&showposts=30") ?> <!-- Main Content --> <h3 class="sectionTitle"><?php wp_title(''); ?></h3> <ul class="small-block-grid-1 large-block-grid-3"> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); if (is_user_logged_in()) { get_template_part('templates/members/content', 'tpgrid'); } else { get_template_part('templates/tour/content', 'tpgrid'); } endwhile; endif; ?> </ul> <?php if ( $wp_query->max_num_pages > 1 ) : // if there's more than one page turn on pagination ?> <?php wp_pagenavi(); ?> <?php endif; ?> <!-- End Main Content --> </div><!-- End large-9 --> <?php if (is_user_logged_in()) { get_sidebar('members'); } else { get_sidebar('tour'); } ?> <?php get_footer(); ?> |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 |
So Fucking Banned
Join Date: Jan 2005
Posts: 3,716
|
I hate messing with themes, I tried adding the code you suggested so it looked like
Code:
<?php query_posts($query_string."&orderby=rand") if (have_posts()) : while (have_posts()) : the_post(); ?> Unfortunately it generated a syntax parse error. Think I will just leave it. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#14 | |
Monger Cash
Industry Role:
Join Date: Jul 2010
Posts: 2,773
|
Quote:
Code:
<?php query_posts($query_string."&orderby=rand"); if (have_posts()) : while (have_posts()) : the_post(); ?> |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#15 |
So Fucking Banned
Join Date: Jan 2005
Posts: 3,716
|
Thanks for your help, it's actually working now but it's displaying all posts random. How do I edit that to only display random posts from a specific category?
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#16 | |
Monger Cash
Industry Role:
Join Date: Jul 2010
Posts: 2,773
|
Quote:
Do you want only a single category of posts to be shown on the categories page? Doing this would render all other category links and pages inoperable if going this route. Do you want to have a fully functional category page that will work with all links and posts on your site and only want posts in the "News" category to display randomly? Do you want a separate page for "News"? There are various ways your question can be interpreted, and many answers depending on what you want specifically so I need a little more info before I offer a solution. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#17 |
So Fucking Banned
Join Date: Jan 2005
Posts: 3,716
|
I have several categories, one of them being for example 'news'. I am wanting to random the posts within this category only.
Currently all posts in all categories are random. Thanks |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#18 | |
Monger Cash
Industry Role:
Join Date: Jul 2010
Posts: 2,773
|
Quote:
Then, just remove the "query_posts($query_string."&orderby=rand");" from the base category.php file, and you should be good to go. And then, for any other categories you may want to display random posts for in the future, simply copy category-news.php (or category-ID.php) to category-slug.php (or category-ID.php, again specifying the numeric ID of said category). More info here: http://codex.wordpress.org/Category_Templates |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#19 |
So Fucking Banned
Industry Role:
Join Date: May 2013
Posts: 215
|
Fuck with the usernames.
|
![]() |
![]() ![]() ![]() ![]() ![]() |