Unusual Request: Use Page title as category definition.
-
One of the page templates is a ‘page-blog_template.php’ I see the call
<?php if(!empty($optimizer['blog_cat_id'])){ $blogcat = $optimizer['blog_cat_id']; $blogcats =implode(',', $blogcat); }else{$blogcats = '';} $args = array( 'post_type' => 'post', 'cat' => ''.$blogcats.'', 'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1), 'posts_per_page' => ''.absint($optimizer['blog_num_id']).''); $the_query = new WP_Query( $args ); ?>
How would i take the page title and use that title as the category to display posts from?
For instance I have a page with the name ‘New Jack City’ and want to display all posts from new-jack-city on that page. I could do a
‘
$title = get_the_title();
$catrep = str_replace(‘ ‘, ‘-‘, $title);
$blogCat = strtolower($catrep);
‘To give me the matching category slug… but then what? I don’t have the chops to see this through :/
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Unusual Request: Use Page title as category definition.’ is closed to new replies.