Display artile category in NSP grid.
Responsive WordPress theme for musicians, bands, artists - easy to configure and various theme features.
- GK User
- Thu Feb 04, 2016 12:56 am
Hi. I am trying to retrieve the category name for articles to display in NSP Grid. Currently the title is displaying with the story lead in.
I am looking at plug-ins/gk-nsp/data_sources/wp/layout_parts.php starting at line 39 (see below). I have customised this file before to change the layout.
Is there a way to pull the article's category name into a variable e.g. $art_category ?
Thanks in advance.
John.
function art_title($i, $only_value = false) {
$art_title = '';
$art_ID = '';
$art_url = '';
$art_title = $this->parent->wdgt_results[$i]->post_title;
$art_ID = $this->parent->wdgt_results[$i]->ID;
$art_url = get_permalink($art_ID);
$art_title_short = GK_NSP_Widget_Helpers::cut_text('article_title', $art_title, $this->parent->config['article_title_len_type'], $this->parent->config['article_title_len']);
I am looking at plug-ins/gk-nsp/data_sources/wp/layout_parts.php starting at line 39 (see below). I have customised this file before to change the layout.
Is there a way to pull the article's category name into a variable e.g. $art_category ?
Thanks in advance.
John.
function art_title($i, $only_value = false) {
$art_title = '';
$art_ID = '';
$art_url = '';
$art_title = $this->parent->wdgt_results[$i]->post_title;
$art_ID = $this->parent->wdgt_results[$i]->ID;
$art_url = get_permalink($art_ID);
$art_title_short = GK_NSP_Widget_Helpers::cut_text('article_title', $art_title, $this->parent->config['article_title_len_type'], $this->parent->config['article_title_len']);
-
- Fresh Boarder
- Joshua M
- Thu Feb 04, 2016 8:59 am
Hi,
Please check your News Show Pro widget "Article layout" tab, you should find "show info block" section here and you can display {CATEGORY} in this place.
Is that ok or you need something more?
Please check your News Show Pro widget "Article layout" tab, you should find "show info block" section here and you can display {CATEGORY} in this place.
Is that ok or you need something more?
-
- Moderator
- GK User
- Fri Feb 05, 2016 12:40 am
I have customised the widget to display in the grid (see attached.) Currently it is displaying the title in the grid. In order to do this I have to name the post with the category name. I need to use the title so it will display in landing summary pages, while maintaining the category name in the grid.
Regards,
John.
Regards,
John.
-
- Fresh Boarder
- GK User
- Fri Feb 05, 2016 2:47 am
Just for futher clarification, I want the title text "Story Heading" in the NSP grid block to be the category name instead of the story title. (see attached).
Regards,
John.
Regards,
John.
-
- Fresh Boarder
- Joshua M
- Fri Feb 05, 2016 9:03 am
I understand now, try with this code:
- Code: Select all
$categories = get_the_category($art_ID);
if(count($categories) > 0) {
foreach($categories as $cat) {
$category = $cat->name;
}
}
-
- Moderator
- GK User
- Fri Feb 05, 2016 11:37 am
Worked great - thank you.
Made a small edit to your code as the code was already in a loop. I just ended up adding it below
$art_url = get_permalink($art_ID);
Regards,
John.
Made a small edit to your code as the code was already in a loop. I just ended up adding it below
$art_url = get_permalink($art_ID);
- Code: Select all
$categories = get_the_category($art_ID);
$art_title = $categories[0]->name;
Regards,
John.
-
- Fresh Boarder
6 posts
• Page 1 of 1