Forum Replies Created

Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter 10PL8

    (@10pl8)

    Figured it out, didn’t extend backbone container. Have marked it as resolved.

    Thread Starter 10PL8

    (@10pl8)

    Apologies, I managed to get it to work using carbon-field-template

    I do however have another question, the window.onbeforeunload keeps firing, but clicking leave on the prompt still saves the options. Do you have any ideas on what could be wrong?

    Thread Starter 10PL8

    (@10pl8)

    Have just sent a message.

    Thread Starter 10PL8

    (@10pl8)

    Hi businessdirectoryplugin,

    Thank you for getting back to me so quickly. I tried every method described in that documentation with no success. Templates will just not override ??

    Current setup:
    /themes
    – /twentyfifteen
    — /business-directory
    — listings.tpl.php
    — single.tpl.php

    Have tried:
    /themes
    – /businessdirectory-themes
    — /my-theme
    — /templates
    —- listings.tpl.php
    —- single.tpl.php

    I have no other plugins active on a clean installation using twentyfifteen.

    Not sure what I am doing wrong?

    Thread Starter 10PL8

    (@10pl8)

    This is what I have so far, I know it needs a lot more work though (Getting loads of errors)

    function get_author_post_taxs( $author_id = false ) {
    	$results = array();
    	if ( $author_id ) {
    
    		$tax_types = get_terms( 'photograph-subject', 'orderby=count&hide_empty=0' );
    
    		$tax_types = array_keys( $tax_types );
    		global $wpdb;
    		$sql = "SELECT DISTINCT post_type FROM $wpdb->posts WHERE post_author = %d AND (post_status = 'publish') AND post_type IN(".implode( ', ', array_fill( 0, count( $post_types ), '%s' ) ).")";
    		$sql = array_merge( array( $sql ), array( $author_id ) );
    		$sql = array_merge( $sql, $post_types );
    		$query = call_user_func_array( array( $wpdb, 'prepare' ), $sql );
    		$results = $wpdb->get_results( $query );
    		if ( $results )
    			$results = wp_list_pluck( $results, 'taxonomy' );
    	}
    	return $results;
    }

    Any help would be very much appreciated ?? or any suggestions or direction…

    Please i’m desperate.

    Thread Starter 10PL8

    (@10pl8)

    keesiemeijer, once again – thank you for your help ??

    I have another question if possible…

    Is there anyway to tailor that function to fetch a specific Post type, but only return the taxonomies that have been posted in.

    I’m basically trying to do the same as the first, but this time display the CPT (there’s only one) categorized by Taxonomy, or do i have to do individual queries for each taxonomy (there are 18) ?

    Thanks in advance.

    Thread Starter 10PL8

    (@10pl8)

    That’s exactly how I tried to implement it. It does exactly what its supposed to do.

    Essentially what I am trying to output for each post type is:

    <div id="uniqueID">
    <h2>Post type name</h2>
    <div><img></div><!--This gets manipulated using jQuery src attr-->
    <ul>
    <!--
    list all relavant posts to current CPT.
    these li's are thumbnails which change the above image when clicked
    -->
    <li>Post type, post 1</li>
    <li>Post type, post 2</li>
    </ul>
    </div>

    The only way I could think of achieving this is getting the counts per post type / per author then outputting the closing tags based on that.

    I am using your function to output a set of links to each of these and then display the relevant <div id=uniqueID”> depending on which link is clicked using jQuery.

    It works well duplicating the WP_Query and loop. But I’m worried about server stress. I currently have 7 query’s (Including the query in your function) – is that too many?

    Thread Starter 10PL8

    (@10pl8)

    Nothing special, i essentially used the array of CPT’s created by your function in my WP_query…

    Thread Starter 10PL8

    (@10pl8)

    Keesiemeijer – last question (I promise this time :))

    I loved your get_author_post_types() function, works exactly how i want it to, to exclude a specific CPT I included the “unset($post_types[‘post_type1’]);” in the actual function to exclude a specific CPT…

    I have tried incorporating the get_author_post_types() function to display my CPT’s to limit the WP_query’s… But every time it returns all posts in all CPT’s, is there any way other than doing individual query’s and reseting it each time for each CPT to separate/categorize each CPT???

    I am super grateful for all your help ??

    Thread Starter 10PL8

    (@10pl8)

    That worked beautifully, thank you very much for your help Keesiemeijer.

    Thread Starter 10PL8

    (@10pl8)

    keesiemeijer that worked perfectly – your a legend!!!

    Last question and I promise to leave you alone ??

    How would I go about doing either (Which ever is easiest):
    – Exclude a specific cpt from query
    OR
    – Retrieve results from an array of post types

    Thanks a million!!!

    Thread Starter 10PL8

    (@10pl8)

    Anyone??? I searched the support forums here and all over the net and was unable to find any sort of answer’s to my questions…

    Any help, even just to point me in the right direction.

    please please help…

    Thread Starter 10PL8

    (@10pl8)

    Any help would be greatly appreciated… I have literally spent days trying to work this out…

    Thread Starter 10PL8

    (@10pl8)

    Ok, here it goes. I am trying to order my custom post types by a custom post meta.

    Basically this works (via post.php) – Works

    and this doesn’t (via edit.php) – Not working

    And I am able to order the post by the custom meta value on frontend.

    My issue is updating/saving via edit.php, this is my code instantiated via require_once ‘plugins/extra-user-fields/sortable-columns.php’; in functions.php

    Code:
    `<?php
    //EDIT meta box added to post edit screen
    add_action(“admin_init”, “admin_init”);
    function admin_init(){
    $screens = array( ‘painting’, ‘page’ );
    foreach ($screens as $screen) {
    add_meta_box(
    ‘painting_ro_sectionid’,
    __( ‘Number’, ‘painting_ro_textdomain’ ),
    ‘painting_ro_inner_custom_box’,
    $screen
    );
    }
    }

    //ADD and replace columns in edit.php for custom post types
    add_filter(‘manage_edit-painting_columns’, ‘add_new_painting_columns’);
    function add_new_painting_columns($painting_columns) {
    $new_columns[‘cb’] = ‘<input type=”checkbox” />’;
    $new_columns[‘title’] = _x(‘Painting Name’, ‘column name’);
    $new_columns[‘number’] = __(‘Number’, ‘column name’);
    $new_columns[‘images’] = __(‘Images’);
    $new_columns[‘author’] = __(‘Author’);
    $new_columns[‘date’] = _x(‘Date’, ‘column name’);
    return $new_columns;
    }

    add_action(‘manage_painting_posts_custom_column’, ‘manage_painting_columns’, 10, 2);
    function manage_painting_columns($column_name, $id) {
    global $wpdb;
    switch ($column_name) {
    case “number”:
    $custom = get_post_custom($post->ID);
    $painting_ro = $custom[‘_painting_ro_my_meta_value_key’][0];
    ?>
    <script type=”text/javascript”>
    var j = jQuery.noConflict();
    j(‘submit’).click(function() {
    var formValues = j(“#update_ro”).serialize();
    var data = { type: ‘save’, action: ‘painting_ro_save_postdata_ajax’, data: formValues }
    j.post( ajaxurl, data, function(message){
    alert(‘Saved’);
    });
    return false;
    });
    </script>
    <form id=”update_ro”>
    <label>Change Order:</label>
    <input type=”text” name=”painting_ro_new_field” value=”<?php echo $painting_ro; ?>”>
    <?php submit_button(); ?>
    </form>
    <?php
    break;
    case ‘images’:
    $num_images = $wpdb->get_var($wpdb->prepare(“SELECT COUNT(*) FROM $wpdb->posts WHERE post_parent = {$id};”));
    echo $num_images;
    break;
    default:
    break;
    }
    }

    add_action( ‘save_post’, ‘painting_ro_save_postdata’ );
    add_action(‘wp_ajax_save_product’, ‘painting_ro_save_postdata_ajax’);

    function painting_ro_inner_custom_box( $post ) {
    wp_nonce_field( plugin_basename( __FILE__ ), ‘painting_ro_noncename’ );
    $value = get_post_meta( $post->ID, $key = ‘_painting_ro_my_meta_value_key’, $single = true );
    echo ‘<label for=”painting_ro_new_field”>’;
    _e(“Add a reorder number”, ‘painting_ro_textdomain’ );
    echo ‘</label> ‘;
    echo ‘<input type=”text” id=”painting_ro_new_field” name=”painting_ro_new_field” value=”‘.($value).'” size=”25″ />’;
    }

    function painting_ro_save_postdata_ajax( $post_id ) {
    global $wpdb;

    $post_ID = $_POST[‘post_ID’];
    $mydata = sanitize_text_field( $_POST[‘painting_ro_new_field’] );

    add_post_meta($post_ID, ‘_painting_ro_my_meta_value_key’, $mydata, true) or
    update_post_meta($post_ID, ‘_painting_ro_my_meta_value_key’, $mydata);

    update_post_meta($post->ID, “_painting_ro_my_meta_value_key”, $_POST[“_painting_ro_my_meta_value_key”]);
    echo ‘Meta Updated’;
    die();
    }

    function painting_ro_save_postdata( $post_id ) {
    global $wpdb;
    $post_ID = $_POST[‘post_ID’];
    $mydata = sanitize_text_field( $_POST[‘painting_ro_new_field’] );

    add_post_meta($post_ID, ‘_painting_ro_my_meta_value_key’, $mydata, true) or
    update_post_meta($post_ID, ‘_painting_ro_my_meta_value_key’, $mydata);

    update_post_meta($post->ID, “_painting_ro_my_meta_value_key”, $_POST[“_painting_ro_my_meta_value_key”]);
    }

    ?>

    Thread Starter 10PL8

    (@10pl8)

    Hi,

    Thanks for that Josh. Constructive guidelines. Will summarize and be more concise when submitting questions.

    “Keep it simple stupid”

Viewing 15 replies - 1 through 15 (of 16 total)