How do I show posts of a particular category?


#1

Hello!

I would like to point a parent menu link (in this case “BEBÉS”) to a page where all baby posts would show exclusively. And in which you could click on the image to take you to the full post.

Even if there was a Blog template I could choose for “BEBÉS” page, it would still show all existing posts, right?

I tried using NextGen plugin to present a thumbnail gallery, but to many user’s surprise it doesn’t feature the possibility to connect a url to each thumbnail.

Does Moesia Pro have a widget or shortcode I could use for the above mentioned objective? One where I could use a filter, an anchor or something?


#2

Hey,

Well you already have the Bebes category here: http://gabrielpinto.pt/category/bebes/
But I’m guessing you want to show only images and titles like you have now on that page you linked?


#3

I don’t really mind having that in fact!

Now if I could find a way to apply that url to the “See All” button of Bebes, and Bebes only.
Then I could it to the other parent pages as well.

I’m looking into the html but can’t find a proper hook to target it correctly.


#4

You can’t do that without code changes for now. Do it like this now if you’re in a hurry and in the next theme update I’ll add an option to link to the category page instead of the blog page.

  • open fp-latest-news.php;
  • find <a href="<?php echo get_permalink( get_option( 'page_for_posts' ) ); ?>" class="all-news"><?php echo $see_all_text; ?></a>
  • replace it with:

<?php $cat = get_term_by('slug', $category, 'category') ?>
<?php if ($category) : ?>
<a href="<?php echo esc_url(get_category_link(get_cat_ID($cat -> name))); ?>" class="all-news"><?php echo $see_all_text; ?></a>
<?php else : ?>
<a href="<?php echo get_permalink( get_option( 'page_for_posts' ) ); ?>" class="all-news"><?php echo $see_all_text; ?></a>
<?php endif; ?>

This should basically link to the category page for the Latest News widgets in which you entered a category slug and it will link to the blog page for those in which you didn’t add the category.
You’ll break your site if you do anything wrong, so only do this if you have FTP access so you can quickly restore it.


#5

Marvellous !!

It’s working fine like this Vlad.
I do use the host file manager to replace damaged files in case of accidents.
I first download it as backup, make the changes within WP and take notes on a text file so I can keep track of what needs changed whenever there’s a theme update.

Got to get started on php, still too confusing to me.

Thanks again!


#6
so I can keep track of what needs changed whenever there’s a theme update

You could use a child theme so you don’t have to worry about updates.


#7

That you be wiser yes, but I tend to complicate things a bit.
Will have to look into creating the child theme one of these days.