jclark5093
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Page of posts by $slugReally not elegant, but I found a solution that works for me for now. It’s hard coded for my 4 categories instead of dynamically generating them, but it’s functional.
If there’s a better solution, please post. I will leave this thread open for a few days.
<?php // assign the variable as current category based on the current page $cat_slug = ''; global $post; $pagename = $post->post_name; if ($pagename =='business') { $cat_slug = 'business-for-sale'; } elseif ($pagename =='commercial') { $cat_slug = 'commercial-listing'; } elseif ($pagename =='residential') { $cat_slug = 'residential-listing'; } elseif ($pagename =='hotels-motels') { $cat_slug = 'hotel-motel-listing'; } query_posts( array( 'category_name' => $cat_slug, 'posts_per_page' => -1 ) ); ?>
Forum: Fixing WordPress
In reply to: Page of posts by $slugI think I realized that I’m trying to make my pages behave like a category.php page. Is there a way to gather a category type for the posts I want to display inside a custom page.php?
Forum: Fixing WordPress
In reply to: Website not workingyou need to go through your host’s control panel (many use CPanel, some use V-Deck, there are others.)
If you don’t use a control panel, use an FTP client to remotely access the files on your hosted server.
Forum: Themes and Templates
In reply to: Page name vs Post name (for custom loop pages?)I think this is in the wrong section.
Moved thread to troubleshooting section (new thread is here), closing this thread.
Forum: Themes and Templates
In reply to: Page name vs Post name (for custom loop pages?)I found a single line that works where ‘business-for-sale’ is the (default?) slug for the category.
<?php query_posts( array( 'category_name' => 'business-for-sale', 'posts_per_page' => -1 ) ); ?>
I’m not sure what the php if statement is for, is it important?
Also, what can I put in that spot for the slug that would be a variable based on the current page (I need 4)?
Forum: Themes and Templates
In reply to: Page name vs Post name (for custom loop pages?)I did some searching through, and think that what I need to alter is the query, not the loop. I should be able to run a standard loop after using a query like this:
if ( is_category( 'category-slug' ) ) : query_posts( array( 'category_name' => 'my-category-slug', 'posts_per_page' => -1 ) ); endif;
but is there a difference between ‘category-slug’ and ‘my-category-slug’? Let’s say a slug is “business” so should my code read:
if ( is_category( 'business' ) ) : query_posts( array( 'category_name' => 'business', 'posts_per_page' => -1 ) ); endif;
or would I need to define ‘category_name’ somewhere (or is that a system recognized name?)