Are you the publisher? Claim or contact us about this channel


Embed this content in your HTML

Search

Report adult content:

click to rate:

Account: (login)

More Channels


Channel Catalog


Channel Description:

WordPress › Support

older | 1 | .... | 315 | 316 | (Page 317) | 318 | 319 | .... | 413 | newer

    0 0

    I have this custom field with the name "en_proceso_class" and the value "en_proceso". It was supposed to add a class to a div element in my post query.

    // Get post meta that is already set
    $custom_values = get_post_meta($post->ID, 'en_proceso_class', true);?>
    <div class="postthumbnail <?php echo $custom_values; ?>">

    But the problem is that if you are on a new post and the custom name "en_proceso_class" is there but the value is empty, I don't want the client to add anything to the class since it's already styled. I thought it's best to convert this into a checkbox. It would be something like "Please check if you want the post to be in process" which will add the class to the post. I did research and again was confused by all those researching... Text field were simple but checkboxes were complicated

    Here's the code in functions.php that are half working. It works in that it adds class, sort off, but the checkbox isn't working by unchecking and checking the box everytime you update. Additionally, when I make a new post, the class is added even when I made sure that I didn't check the box when I published the post. Could you check what's wrong with the code.

    add_action( 'add_meta_boxes', 'cd_meta_box_add' );
    function cd_meta_box_add()
    {
        add_meta_box( 'my-meta-box-id', 'My First Meta Box', 'cd_meta_box_cb', 'post', 'normal', 'high' );
    }
    
    function cd_meta_box_cb()
    {
        // $post is already set, and contains an object: the WordPress post
        global $post;
        $values = get_post_custom( $post->ID );
        $text = isset( $values['my_meta_box_text'] ) ? $values['my_meta_box_text'] : '';
        $check = isset( $values['en_proceso'] ) ? esc_attr( $values['en_proceso'] ) : '';
    
        // We'll use this nonce field later on when saving.
        wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );
        ?>
        <p>
            <input type="checkbox" id="en_proceso_class" name="en_proceso_class" <?php checked( $check, 'on' ); ?> />
            <label for="en_proceso_class">Please check if this is in process</label>
        </p>
        <?php
    }
    
    add_action( 'save_post', 'cd_meta_box_save' );
    function cd_meta_box_save( $post_id )
    {
        // Bail if we're doing an auto save
        if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
    
        // if our nonce isn't there, or we can't verify it, bail
        if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return;
    
        // if our current user can't edit this post, bail
        if( !current_user_can( 'edit_post' ) ) return;
    
        // now we can actually save the data
        $allowed = array(
            'a' => array( // on allow a tags
                'href' => array() // and those anchors can only have href attribute
            )
        );
    
        // This is purely my personal preference for saving check-boxes
        $chk = isset( $_POST['en_proceso_class'] ) && $_POST['my_meta_box_select'] ? 'on' : 'en_proceso';
        update_post_meta( $post_id, 'en_proceso_class', $chk );
    }

    By the way, I got that from this tutsplus tutorial, http://code.tutsplus.com/tutorials/how-to-create-custom-wordpress-writemeta-boxes--wp-20336.


    0 0

    Can somebody please explain why the first one works (prints "5 berichten"), but the second one does not (prints "5 messages")?

    $amount = 5;
        printf(__("%s messages", "plugin-name"), $amount );
        printf(_n("%s message", "%s messages", $amount, "plugin-name"), $amount );

    I assume it's already asked, I have searched for a while, but couldn't find anything.

    Thanks in advance!


    0 0

    Hi there,

    i would like to remove completely the Toolbar for all User and also Admins. I currently use a Plugin for that and would like to do this via Theme functions.

    So i googled a bit arround and found some codes to disable it. But Sadly no one of it removed it.

    Currently i tried

    add_filter('show_admin_bar', '__return_false');
    remove_action('wp_head', '_admin_bar_bump_cb');
    show_admin_bar(false);

    0 0

    I want to create a template within my plugin which will display the entry in a certain way.

    I've added the template no problem:

    add_filter('single_template', 'mjt_class_single_templates');
    add_filter('archive_template', 'mjt_class_archive_templates');

    however within the template I still want to inherit the theme settings to some extent.

    So within my template file I need something like this:

    get_header();
    
    while (have_posts() ): the_post();
    
       <!-- inherit stuff from the theme to open the entry-->
       <!-- do my own formatting of title -->
        the_title();
       <!-- do my own formatting of content -->
        the_content();
       <!-- inherit stuff from the theme to close the entry-->
    endwhile;
    get_footer();

    I have a feeling I need to do something with get_template_part but ... I can't work out what.

    Any help much appreciated everyone.


    0 0

    I'm crating a plugin to add a simple navigation to posts within a specific custom post type. But it seems like to use next_post_link/previous_post_link you have be working within a theme. Is there any way to get these links from within a plugin?


    0 0

    I want to change the way the author and date line looks for a comment.

    It looks like this:

    author says:
    November 3, 2015 at 4:06 am Edit

    I want to change it to

    author said, on November 3, 2015 at 4:06 am: Edit Comment

    It is formatted in the comment() function in comment-template.php core file. The function is defined as private and a comment line in the header says : "@access protected"

    Is there a way I can include a modified comment() function in my functions.php file?

    I now there is the add_filer() function but I'm unsure as to how to use it. The first argument is the hook name. I don't know if there a hook for comment() or, if there is, its name.

    Is there someway I can override the comment() function's formatting the the text I showed, above?

    Bob


    0 0

    I'm building a system where the products are read in from a 3rd party. I have these read in and stored in a database. This third party can add products, edit products and remove products also.

    What I want is something like a custom post type where each of these products are selectable to add extra content such as images, copy, maybe some ACF data, meta (using the third part plugin), etc.

    Any one know how to do this? I don't want the original data editable just to expand upon it.

    Anybody know of a way to do this? Or some sort of a clue? Thank you in advance!


    0 0

    Hello, I am authoring a WP Widget plugin, and have run into a problem. My Widget's Admin Form is quite involved, and uses an external javascript file to manipulate fields, collapse sections, etc. This external javascript is enqueued into the Widget Admin Panel like this:

    function enqueue_admin_scripts() {
      wp_register_script('mp3-admin-script', plugins_url('assets/js/wp-mp3-admin.js' , __FILE__ ), array( 'jquery' ));
      wp_enqueue_script('mp3-admin-script');
    }
    add_action('admin_enqueue_scripts','enqueue_admin_scripts');

    This works fine initially, but when you make a change to the Widget's Admin Form and click the "Save" button, the page is reloaded but WITHOUT any of the JavaScript.

    If I refresh the page, the javascript is loaded again and resumes working, but each time the Widgets' changes are saved, the javascript stops functioning.

    Any ideas why 'admin_enqueue_scripts' doesn't get executed after a widget is "Saved"?

    Thanks for looking!


    0 0

    Hi,

    We have orders printing to a zebra label printer via our woocommerce and a plugin called print orders, we are trying to add pages numbers to the label using dompdf, I have searched the forums and found the code but do not know where to put it, I have tried google cloud plugin header as it is type/php, I have tried functions.php and tried the template file from the plugin but it does not work.

    Any advice this is the code below

    <script type="text/php">
    if ( isset($pdf) ) {
    $pdf->page_script('
    if ($PAGE_COUNT > 1) {
    $font = Font_Metrics::get_font("Arial", "normal");
    $size = 7;
    $pageText = "Page " . $PAGE_NUM . " of " . $PAGE_COUNT;
    $y = $pdf->get_height() - 80;
    $x = ($pdf->get_width() - Font_Metrics::get_text_width($pageText, $font, $size) ) / 2 ;
    $pdf->text($x, $y, $pageText, $font, $size);
    }
    ');
    }
    </script>


    0 0

    Using print_media_templates i managed to extend default gallery to more like multi-gallery using different output based on selected type.
    For example first custom option:

    <select name="type" data-setting="type">
    	<option value="default">Default</option>
    	<option value="grid">Responsive Grid</option>
    	<option value="masonry">Masonry</option>
    	<option value="slider">Slider</option>
    	<option value="carousel">Carousel</option>
    </select>

    define base type of gallery output. Then there's lot of option for each type (grid columns, paddings, slider speed, animation etc.) so it's rather long. The question is how can display only one part of settings based on currently selected "type" ?

    It was easy to do it for metaboxes or customizer but i can't get it working there since markup is different (html select / input / checkbox ).

    Thanks


    0 0

    Woocommerce: Does anyone know if it is posable to force the currency of a user from their user profile in admin. I currently have a field with a radio option for GBP or EURO using UPME profile plugin which produces a user meta key, but I need some way of forcing the currency to the selected radio option per user account.


    0 0

    Hi, I need to open a prompt when editing a post.

    With this code I'm able to update post meta:

    function duvod( $post_id, $post )
    {
    	if ( wp_is_post_revision( $post_id ) || $post->post_type != 'inzerat' )
    		return;
    
    		update_post_meta($post_id, 'duvod_odmitnuti', 'vsuk');
    
    }
    add_action( 'save_post', 'duvod', 10, 2 );

    But when I try to change it - open a javascript prompt or php echo but none of them is working.

    Is there any restriction when using the 'save_post' action?


    0 0

    Hey!

    Im new to wordpress and havent found any other thread about how to do this. At the moment when Im using this shortcode it creates a "link-title" with the link. I want the link-title to the right but also the same link for my title-text. Is this possible in any way?


    0 0

    I installed woocommerce on a site with a specific number of users who will be able to access the password protected store.

    Q: is it possible to hide a product from all users EXCEPT for a few customers.
    I would like to create a function that would be...

    `hide product ID (from all) except for user ID: 93, 64, 22 etc.

    Thanks in advance.


    0 0

    Is there a function similar to current_user_can() which looks at all sites on my multi site network?

    Alternatively could you suggest some code which will accomplish this?

    Thanks for your help in advance.


    0 0

    I have created a custom taxonomy and added custom fields, one of which is an image. It works fine in that I can select an image, preview it and save it to the options table / recall it but there is one silly bug that has me scratching my head.

    When I add a new taxonomy, all the fields are cleared except the preview image (an img element) and the image ID which is he value saved (a hidden field, is that perhaps related?).

    It appears as though the page isn't reloaded, just modified through javascript so I'm wondering whats the best course of action?

    Is there a reason this might be happening? The img element I understand not reseting, but the id input I don't quite understand.

    Is there a javascript event I can hook into so that I can clear these fields on succesful save?

    Thanks in advance.
    Ken


    0 0

    Sorry for my bad english, This is my code
    <?php
    $terms = get_terms('loai-tin', array(
    'orderby' => 'id',
    'order' => 'ASC',
    'hide_empty' => 1
    ));
    foreach ($terms as $term) {
    $args = array(
    'post_type' => 'tin-bat-dong-san',
    'post_status' => 'publish',
    'posts_per_page' => 10,
    'tax_query' => array(
    array(
    'taxonomy' => 'loai-tin',
    'field' => 'slug',
    'terms' => $term->slug,
    )
    )
    );
    $query = new WP_Query($args);

    How to add pagination for this loop. Help me please :(


    0 0

    Would like to know is there any way to have a comment button on the bottom of the post linked to the comment form on its own page. After submitted the form on that page, the comment get the post id and automatically posted on the linked page.

    I try to look around for a while and the best i could come up with is the button with comment pop up.

    The idea is the create the food review website with the comment section as a review form, and instead of having a form by the end of the post page, we would like to have a "submitted a review" button and linked to a custom form on its own, after filled out the form the review get posted back.


    0 0

    Is there any way to make WP_Customize_Image_Control use a specific image size? All I could find was a way to recommend a size


    0 0

    Hi guys,
    I've been trying to fix the share image on my blog so that when it shares on Facebook people can see that it's a video and Facebook sees it as a video- Not only have I not figured that out, now I'm sharing the image a sleeping cat and I don't know where it came from. I never added it. Sometimes it also shares a picture that I had but deleted. I'm using and old theme- Luxury- I keep trying to find that image but can't figure it out. I added and ran WP Super Cache and that did not help.
    Thanks for your help.


older | 1 | .... | 315 | 316 | (Page 317) | 318 | 319 | .... | 413 | newer