I\'m trying to echo custom posts sub category link as a view more option.For the last week, i am trying to do that, but i just can\'t find the right way. I\'ve tried, category links, terms, with args, id..whatever i could think of or find here. The only way currently to show is with the id but here i will have to add a number, which is not the option i want. So let me give you more info.
First i created custom posts (note that i removed some options here because they are not needed, so to make it shorter)
$args = array(
\'taxonomies\' => array( \'category\', \'post_tag\', \'fixture\' ),
\'public\' => true,
\'show_in_menu\' => true,
\'publicly_queryable\' => true,
\'has_archive\' => true,
\'query_var\' => true,
\'rewrite\' => true,
\'query_var\' => true,
\'capability_type\' => \'post\'
);
register_taxonomy(
\'fixs_cat\',
\'match\',
array(
\'label\' => __( \'Fixture Categories\', \'ko-text\' ),
\'rewrite\' => array( \'slug\' => \'fixture\' ),
\'hierarchical\' => true,
\'query_var\' => true
)
);
register_post_type( \'match\', $args );
}
Then i created widget which will display them. It\'s a tabbed widget so i wont add all tabs options because all are the same, only number changes from 1 to 10.
public function widget( $args, $instance )
/* Widget variables. */
$fix_name1 = $instance[\'fix_name1\'];
$fix_cat1 = $instance[\'fix_cat1\'];
$fix_num1 = $instance[\'fix_num1\'];
$fix_name2 = $instance[\'fix_name2\'];
$fix_cat2 = $instance[\'fix_cat2\'];
$fix_num2 = $instance[\'fix_num2\'];
public function form( $instance ) {
TODO: Define default values for your variables
$defaults = array(
\'sort\' => \'latest\',
\'$fix_name1\' => 10,
\'$fix_name2\' => 10,
);
$instance = wp_parse_args(
(array) $instance
);
Then in widget setting I\'ve made option so the user can select title, category and how many post does he want to show from selected custom post category. Can\'t post it here, without breaking it so here
http://pastebin.com/hjpdrdnA
And the final thing is actual loop which displays those posts in widget
if($fix_name1) { ?>
\'match\',
\'posts_per_page\' => $fix_num1,
\'tax_query\' => array(
array( \'taxonomy\' => \'fixs_cat\',
\'field\' => \'slug\',
\'terms\' => $fix_cat1 ))
)); while($recent->have_posts()) : $recent->the_post();?>
//Stuff to display
} ?>
For an example this code with term link lists all categories, but i want only the one which is selected under tab1 and is here $fix_name1
http://codex.wordpress.org/Function_Reference/get_term_link
- here for terms I added a general category like get_terms(\'fixs_cat\')
//Something short like this echo $fix_cat1;
displays needed category but the main custom post category is missing in the link it should be fixture/category selected and this shows only /category selected.
//this does the same from the same code example
$fixs = get_terms(\'fixs_cat\');
foreach($fixs as $fix) { ?>
if ($fix->slug == $fix_cat1)
Any ideas how to solve this?