WordPress.org

Ready to get started?Download WordPress

Forums

Featured Posts Grid
[resolved] Dynamically select tag or category? (5 posts)

  1. digigirl
    Member
    Posted 2 years ago #

    I would like to use this on my Archives / Category pages. I've installed it and plugged the code into my Archives.php file and it looks great. But, it is displaying all posts, rather than the specific tag or category.

    Let me state right up front - I don't know PHP. I've chimped around a little, but have been unable to get it to do anything but either all posts or nothing at all.

    Is there a way to make this dynamically display only the posts for the category or tag that was clicked to get to the page?

    http://wordpress.org/extend/plugins/featured-posts-grid/

  2. digigirl
    Member
    Posted 2 years ago #

    Okay, I've managed to get this to correctly do categories, but not tags. Here is the code I'm using. Can anyone tell me how to fix this so it will work with both categories and tags?

    I just used the same code for the category, subbing in tag, but it's not working, so it must need to be different.

    Thanks for any help. I really don't know PHP at all - this is just me chimping.

    `<?php if (function_exists('fpg_show')) {
    $args = array_merge( $wp_query->query, array( 'showposts' => '', 'category__in' => array(get_query_var('cat')) ) );
    echo fpg_show($args);
    }?>

    <?php if (function_exists('fpg_show')) {
    $args = array_merge( $wp_query->query, array( 'showposts' => '', 'tag__in' => array(get_query_var('tag')) ) );
    echo fpg_show($args);
    }?>

  3. digigirl
    Member
    Posted 2 years ago #

    Got it! Here is the final code, if anyone else wants to do this. This produces a grid style archives page for any category or tag that is clicked:

    <?php if (function_exists('fpg_show')) {
                $args = array_merge( $wp_query->query, array( 'orderby' => 'title', 'order' => 'ASC', 'showposts' => '', 'category__in' => array(get_query_var('cat')) ) );
                echo fpg_show($args);
            }?>
    
    <?php if (function_exists('fpg_show')) {
                $args = array_merge( $wp_query->query, array( 'orderby' => 'title', 'order' => 'ASC', 'showposts' => '', 'tag__in' => get_query_var('posttag') ) );
                echo fpg_show($args);
            }?>
  4. djphatjive
    Member
    Posted 2 years ago #

    I have a reverse problem. I only want it on my homepage and not in categories and tag pages. How would I do this? I no nothing about coding sorry :)I installed it in my homepage theme file and it shows up everywhere.

  5. tallydigtalbiz
    Member
    Posted 2 years ago #

    I am trying to display a select group of posts on one specific page using short code. I've tried placing code in various places and still get error message below.
    -------------------------------------------------
    page.php (code below)

    <?php
    /**
    * @package WordPress
    * @subpackage KidsToys
    */

    $from='page';
    include("layout.php");

    }?>

    <?php if (function_exists('fpg_show')) {
    $args = array(
    'cat' => '8',/* comma separated list of category ids to include (put '-' in front of ids to exclude) */
    'tag' => 'discount-directory' /* comma separated list tag slugs to include */);
    echo fpg_show($args);
    }?>
    ---------------------------------------------------
    Result: (Error below)

    Parse error: syntax error, unexpected '}' in /homepages/12/d154028271/htdocs/tallahasseekidsclub.com/wp-content/themes/kids_toys/page.php on line 12

    -----------------------------------------------------
    Any advice

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic