Forum Replies Created

Viewing 14 replies - 1 through 14 (of 14 total)
  • Well, you can try to check $_POST[‘tax_input[gender]’] on init action but this will be kind of dirty hack.

    Why not use own meta box with fixed terms?
    If you use custom posts you will work with custom metaboxes anyway.
    Your metabox content will be very simple, something like this:

    <?php $tax_name = 'gender';?>
    <div class="tagsdiv" id="<?php echo $tax_name; ?>">
    	<div class="jaxtag">
    	<div>
    	<p>Description</p>
            <select name="tax_input[<?php echo $tax_name;?>]" id="tax-input-<?php echo $tax_name; ?>">
              <?php foreach(array('male', 'female') as $g):?>
                <option <?php echo ($g == get_terms_to_edit( $post->ID, $tax_name ))?'selected':''><?php echo $g; ?></option>
              <?php endforeach; ?>
            </select>
            </div>
    </div>
    </div>

    It should be something like this:

    if ( ! empty($search) ) {
    $search_parts = array();
    foreach(explode(',', $search) as $search_item) {
      $search_item = like_escape(trim($search_item));
      $search_parts[] = "(link_url LIKE '%$search_item%') OR (link_name LIKE '%$search_item%') OR (link_description LIKE '%$search_item%')";
    }
    
    $search = " AND ( ". join(' OR ', $search_parts) ." ) ";
    }

    Forum: Hacks
    In reply to: Hiding Article Tags

    Hi,

    Check wp_tag_cloud function docs for arguments. There is ‘exclude’ arg for your purpose.
    Tag Cloud Widget use ‘widget_tag_cloud_args’ filter before sending args to wp_tag_cloud. So you can set your function to add ‘exclude’ arg to them.

    Sorry, dont noticed you alredy have array in $cat.

    <?php
                // page id 224 will get category ID 7 posts
                if (is_page('224') ) {
                $cat = array(7,8); //will get posts for 7 and 8 categories
                } else {
                $cat = '';
                }
    
                $showposts = 1; // -1 shows all posts
                $do_not_show_stickies = 1; // 0 to show stickies
                $args=array(
    			   'category__in' => $cat,
                   'showposts' => $showposts,
                   'caller_get_posts' => $do_not_show_stickies,
                   'orderby' => 'rand'
                   );
                $my_query = new WP_Query($args); 
    
                ?>

    Hi,

    Well, it cant sort by 'meta_key' => '_datetime['start_date']'
    All these options used to build correct SQL query and it’s not supposed to sort by part of serialized value because this is slow and ineffective.

    Solution is simple, you should put each value to own meta and then you will be able to sort them.

    This code works only if terms others than male/female dont exists.
    Try to change new WP_Error('invalid_term', __('Invalid term'));
    to new WP_Error();

    Oh, thats add_filter chnge it to:
    add_filter('pre_insert_term', 'check_right_term', 10, 2);

    About terms edit box.
    Thats quite tricky. You should remove default tags metabox using remove_meta_box on ‘add_meta_boxes’ action and then add your metabox with strict select term selection.
    You can find default tags metabox render function in wp-admin/includes/meta-boxes.php it called post_tags_meta_box
    You can use it like prototype for your metabox.

    Hi,

    Try this:

    add_filter('pre_insert_term', 'check_right_term');
    function check_right_term($term, $taxonomy)
    {
      if($taxonomy == 'gender' && !in_array($term, array('male', 'female'))
        return new WP_Error('invalid_term', __('Invalid term'));
    
      return $term;
    
    }

    Hi,

    POST should not exist on post edit page.
    WP uses the “redirect to view after action” scenario which is only right way to handle POST requests. Other words:
    1. handle POST data, save post
    2. redirect to /wp-admin/post.php?post=YourpostID&action=edit
    Your “display_post_meta_boxes” works after second stage so POST doesnt exists.
    You can get your value using get_post_meta if they was properly saved on save_post action.

    Hi,

    Unfortunately as I can see from source code this function dont split “search” param by ‘,’ as it does with ‘include’ and others.
    So, there is no way.

    You can copy this function to your plugin and change this behavior ??
    Also you can make several calls and then merge results.

    Hi,

    Try change:

    $args=array(
                   'category__in' => $cat,
                   'showposts' => $showposts,
                   'caller_get_posts' => $do_not_show_stickies
                   );

    To:

    $args=array(
                   'category__in' => array($cat1, $cat2), //your multiple categories
                   'showposts' => $showposts,
                   'caller_get_posts' => $do_not_show_stickies,
                   'orderby' => 'rand'
                   );

    Forum: Hacks
    In reply to: Changing URL Structure

    Hi,

    You just need to add custom slug in register_post_type call.
    add
    'rewrite' => array('slug' => 'SomethingElse')

    to arguments array.

    Hi,

    You can use this code:

    foreach(get_posts(array('author' => $author_id)) as $post)
    {
      //do what you want todo with post using $post->ID
    }

    Or low level db access method:

    global $wpdb;
    $pids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d AND post_status = 'publish' AND post_type='post'", $author_id));
    foreach($pids as $post_id)
    {
      //do what you want to do with post using $post_id
    }

    Hi,

    register_post_type function build permalink with slug/post_type structure.
    so setting slug to ” will not help.

    WP need to know post type from query to show post.
    You can try hook some of query parsing actions/filters, check by post slug thats your custom post and add query param post_type to wp query before it will get post from db.

    Hi Keith,

    Using “PHP Code Widget” you can do this with such code:

    <?php
    if(is_single())
    {
      global $post;
      $post_link = get_post_meta($post->ID, 'soy_post_link', true);
    
      echo "<a href=\"$post_link\">Visit Source</a>";
    }
    ?>

    Let me know if you need something more.

Viewing 14 replies - 1 through 14 (of 14 total)