WordPress.org

Ready to get started?Download WordPress

Forums

Mystique theme: Display category on Featured slide (17 posts)

  1. elindquist
    Member
    Posted 3 years ago #

    By default, the Featured Posts slides in the Mystique theme read:

    Post Title
    Stripped post content here.

    I would like to make it read:

    Category: Post Title
    Stripped post content here.

    I've looked over the code in featured-posts.php, but don't know how to achieve my desired change. Any ideas?

  2. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

  3. elindquist
    Member
    Posted 3 years ago #

    Yes, that's the one.

    Also, my site is here: http://www.looseleafstories.com

  4. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    All right, I am looking at the theme for you.

  5. elindquist
    Member
    Posted 3 years ago #

    Thanks!

  6. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    I belive that you can achive that with:

    <?php
    $category = get_the_category();
    echo $category[0]->cat_name;
    ?>

    Here is the code from: ../featured-posts.php
    http://wordpress.pastebin.com/vfjJXEqK

    Also see:
    http://codex.wordpress.org/Function_Reference/get_the_category#Show_the_First_Category_Name_Only

    The code is already in I didn't style anything, just placed to code in for you. You might need some additional adjustments to fit this into your featured slider.

  7. elindquist
    Member
    Posted 3 years ago #

    In <?php $category = get_the_category(); echo $category[0]->cat_name; ?>
    the category being pulled is 0 only, which is my blog. How might I set it to pull the category of the attached post?

  8. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    So what happens when you put in the above code?

  9. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    You can also do this:

    <?php query_posts('cat=1&showposts='.get_option('posts_per_page')); ?>

    cat=1,2,3,4 etc

    http://codex.wordpress.org/Category_Templates#What_categories_do_you_show_to_the_visitors.3F

  10. elindquist
    Member
    Posted 3 years ago #

    Sorry, it hit my bedtime last night. The first string gave this result: http://www.looseleafstories.com/beta/titling.jpg
    I added the h2 formatting, but the category listed is incorrect.

  11. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    It was bedtime for me as well :) so no problem. Just wondering what about if you add simple:

    <?php the_category(''); ?>
  12. elindquist
    Member
    Posted 3 years ago #

    It added a link to the category name, but it still pulling Blog, rather than the correct one.

  13. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    I'm really not sure why they don't display right over in your theme.

    Let's try this too:

    echo '<h2><a href="'.the_category(' ') .get_permalink($featured_post['ID']).'">'.mystique_strip_string(70, strip_tags($featured_post['post_title'])).'</a></h2>';
  14. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    And or:

    <div class="details clearfix">
                 <?php
                  mystique_post_thumb('featured-thumbnail', $featured_post['ID']);
                  echo '<h2><a href="'.get_the_category($featured_post['ID']) .get_permalink($featured_post['ID']).'">'.mystique_strip_string(70, strip_tags($featured_post['post_title'])).'</a></h2>';
                  echo '<div class="summary">'.mystique_strip_string(420, strip_tags(strip_shortcodes($featured_post['post_content']))).'</div>';
                 ?>
                </div>
  15. elindquist
    Member
    Posted 3 years ago #

    Both results are still pulling the wrong post category. Oh, for monkey's sake, this is way too much work for a minor change! I'll just change the post title to "Category: Title"!

  16. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    Sorry because it didn't work out the way you want I really tried all. You might want to check with theme author as well http://digitalnature.ro/

  17. elindquist
    Member
    Posted 3 years ago #

    You were awesome. Thanks for your help. There must be something strange going on in the code - I can't for the life of my figure out why it keeps bringing up the wrong category.

Topic Closed

This topic has been closed to new replies.

About this Topic