Recent Post Widget

resolved (5 posts) (2 voices)

  1. AlexBepunkt
    Member

    Hello,

    This might be a little out of the normal routine:

    Talking about the Recent Post Widget: I don't want to show visitors the date of recent posts. Instead the categories should come up. This works fine for posts.

    Example: http://www.mouseclick.com/unterwegs/thailand/shark-attack/

    Now, when I add the widget to a page the category array is empty??

    Example: http://www.mouseclick.com/uber-mich/

    Yes, I tweaked the code a little at widget-recent.php:

    $meta_output = '[post_terms taxonomy="category" text=' . __( 'in ', MYSITE_TEXTDOMAIN ) . '] ';
    .
    .
    /* $out .= apply_filters( 'mysite_widget_meta', do_shortcode( '[post_date]' ) );
    */
    if( !empty( $meta_output ) )
    $out .= '<span class="post_neuer_beitrag">' . $meta_output . '</span>';
    .
    .
    echo apply_atomic_shortcode( 'post_meta', $out );

    /* echo $out; */

    Any idea how to fix this for static pages?

    Cheers,
    Alexander

    Posted 4 years ago #
  2. Elliott
    Support

    Hello AlexBepunkt,

    You can add this,

    $out .= '[post_terms taxonomy="category" text="' . __( '<em>in</em>', MYSITE_TEXTDOMAIN ) . ' "] ';

    To display the categories.

    Posted 4 years ago #
  3. AlexBepunkt
    Member

    Hi Ellliot,

    That is quite similar to what I posted and gives me a "[post_terms taxonomy="category" text="in" in both post & pages?

    With the code above I was at least able to display the categories in posts. Still it doesn't work for posts...??

    Posted 4 years ago #
  4. Elliott
    Support

    Did you add it? You can also use this function to grab the category, http://codex.wordpress.org/Function_Reference/get_the_category.

    Posted 4 years ago #
  5. AlexBepunkt
    Member

    Yes, I added the code you suggested. But as I said, it echos "[post_terms taxonomy="category" text="in" instead of the categories.

    But the function reference worked great !!

    Thanks for pointing in the right direction.

    Posted 4 years ago #

Reply

You must log in to post.

Construct WordPress Theme
Construct wordpress theme
Myriad WordPress Theme
Myriad wordpress theme
Method WordPress Theme
Method wordpress theme
Fusion WordPress Theme
Fusion wordpress theme
Elegance WordPress Theme
Elegance wordpress theme
Echelon WordPress Theme
Echelon wordpress theme
Dejavu WordPress Theme
Dejavu wordpress theme
Modular WordPress Theme
Modular wordpress theme