Skip to content

Instantly share code, notes, and snippets.

@gugaalves
Last active January 31, 2019 01:05
Show Gist options
  • Select an option

  • Save gugaalves/15d946a92b2b98197a8b9646b0ce1ccc to your computer and use it in GitHub Desktop.

Select an option

Save gugaalves/15d946a92b2b98197a8b9646b0ce1ccc to your computer and use it in GitHub Desktop.

Revisions

  1. Guga Alves revised this gist Jan 30, 2019. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion shortcode-category.php
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@
    // Add Shortcode
    function button_category($post_id) {
    $getpost = get_posts( array('number' => 1, 'offset' => 1) );
    $category = get_the_category( $post_id );

    $return = '<a href="'. esc_url( get_category_link( $category[0]->term_id ) ) .'">Ver ' . $category[0]->cat_name . '</a>';
  2. Guga Alves created this gist Jan 30, 2019.
    10 changes: 10 additions & 0 deletions shortcode-category.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    // Add Shortcode
    function button_category($post_id) {
    $getpost = get_posts( array('number' => 1, 'offset' => 1) );
    $category = get_the_category( $post_id );

    $return = '<a href="'. esc_url( get_category_link( $category[0]->term_id ) ) .'">Ver ' . $category[0]->cat_name . '</a>';

    return $return;
    }
    add_shortcode( 'button-category', 'button_category' );