Support » Plugin: Custom Content Type Manager » Turn data inputed in to a text custom field in to a button

  • Resolved hessian.andy


    Hey, i’m a bit stuck and i’m probably being stupid. i’ve created a custom post type called “shows” and i want a Buy Tickets button that links to external ticket vendors. i’ve created a text field for people to input the url: of which ever site the tickets for that particular show are. But its not working i tried the output filter “to_link” but it says “Referenced post not found.” and if i try to_link_href i get click here but it just reloads the page.
    Any help would be welcome cheers

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor fireproofsocks


    Don’t complicate it with output filters: just print the text you want in a link and style it to look like a button. It’s just a CSS question.

    <a href="<?php print_custom_field('xxxx:raw'); ?>" class="looks_like_button" >

    Thanks a lot it works a treat! one other thing i was wondering i included a date custom field and i was wondering how to use that to arrange posts? I have a page that pulls in all the “shows” post types and shows the featured image but it orders them by the date they were added it would be cool to have them in order of when the shows are taking place if you know what i mean.
    Anyway thanks for getting back to me and well done with the plugin its awesome.

    Plugin Contributor fireproofsocks


    If you want to use a date field to sort by, then it’s imperative that you store your data in a good format. I always store dates in the MySQL format: YYYY-MM-DD HH:MM:SS

    That means that everything sorts correctly because a year is greater than a month is greater than a day etc. If you want to format that date differently for your users, then fine: use PHP’s date functions to modify it when you print it. I built a lot of convenience stuff into GetPostsQuery, so you could do something like this in your theme file

    require_once(CCTM_PATH.'/includes/GetPostsQuery.php'); // if necessary
    $Q = new GetPostsQuery();
    $args = array();
    $args['post_type'] = 'my_events'; // for example
    $args['orderby'] = 'event_date';   // or any reg. or custom field
    $args['date_format'] = 2; // or any valid date format.
    // Shortcuts for the date_format function:
    		// 1 =	'F j, Y, g:i a' 	March 10, 2011, 5:16 pm
    		// 2 =	'j F, Y'			10 March, 2011
    		// 3 =	'l F jS, Y'			Thursday March 10th, 2011
    		// 4 =	'n/j/y'				3/30/11
    		// 5 =	'n/j/Y'				3/30/2011	
    $results = $Q->get_posts($args);
    // print each result out the way you want, as list items, paragraphs etc.
    // etc.

    See the following wiki pages for examples:

    Thanks again for getting back to me so quick. I couldn’t get what you suggested to work so i did this and it seems to do the job

    $args = array(
    ‘meta_key’ => ‘show_date’,
    ‘orderby’ => ‘meta_value’,
    ‘order’ => ‘ASC’,
    ‘post_type’ => ‘shows’,
    ‘posts_per_page’ => -1 );

    $loop = new WP_Query( $args );

    Cheers Andy,

    Plugin Contributor fireproofsocks


    There are lots of examples for how to use GetPostsQuery on the wiki, and it’s more thorough without the inane caveats of global variables and other WP nonsense, but if WP_Query works for you, go with it.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Turn data inputed in to a text custom field in to a button’ is closed to new replies.