• Heroes of Internet! I need your help!
    This is the thing, I’m running a site with a «pinterest» type of template which shows an infinite posts «excerpt» in the main page/ index page. Each of this thumbnail posts, got a footer bar space with the «post data» meta tag information.

    I would like to know how I can change that «data tag» to a «post views tag» editing the template code, without breaking anything if possible.

    I was able to find the exact location of the code with the meta tag, but I don’t have the skills to understand the code 100% right and change it for the «post views» tag…

    ———- code section start ———-
    <hr>
    <p>
    <label><?php echo __(‘Pinboxes Metadata’, ‘pbpanel’); ?></label>
    <span class=»helptext»><?php echo __(‘Choose whether to show the date and number of comments’, ‘pbpanel’); ?></span>
    <label class=»checkbox» for=»pbpanel_pinbox_show_comments»>
    <input type=»hidden» value=»0″ name=»pbpanel_pinbox_show_comments»>
    <input type=»checkbox» <?php if (get_option(‘pbpanel_pinbox_show_comments’) == 1) { ?> checked=»checked» <?php } ?> value=»1″ id=»pbpanel_pinbox_show_comments» name=»pbpanel_pinbox_show_comments»>
    <span class=»mark»><?php echo __(‘Show number of comments’, ‘pbpanel’); ?></span>
    </label>
    <label class=»checkbox» for=»pbpanel_pinbox_show_postdate»>
    <input type=»hidden» value=»0″ name=»pbpanel_pinbox_show_postdate»>
    <input type=»checkbox» <?php if (get_option(‘pbpanel_pinbox_show_postdate’) == 1) { ?> checked=»checked» <?php } ?> value=»1″ id=»pbpanel_pinbox_show_postdate» name=»pbpanel_pinbox_show_postdate»>
    <span class=»mark»><?php echo __(‘Show post date’, ‘pbpanel’); ?></span>
    </label>
    </p>
    <hr>

    ———- code section end ———-

    There is also a comments tag option but within the template options I could switch that off, my intention is to change or add the option to show the post views instead of comments and or post date. Any kind of help will be appreciated, thanks for your time in advance!

    La página con la que necesito ayuda: [accede para ver el enlace]

Viendo 2 respuestas - de la 1 a la 2 (de un total de 2)
  • Moderador almendron

    (@almendron)

    En español, por favor.

    Espero no haber malinterpretado!

    Lo que puedes hacer es lo siguiente, colocas este código en donde está el código de la fecha
    <?php echo getPostViews(get_the_ID()); ?>

    y en functions.php colocas el siguiente código:

    function getPostViews($postID){
    	$count_key = 'post_views_count';
    	$count = get_post_meta($postID, $count_key, true);
    	if($count==''){
    		delete_post_meta($postID, $count_key);
    		add_post_meta($postID, $count_key, '0');
    	return "0 Visitas";
    	}
    	return $count.' Visitas';
    }
    function setPostViews($postID) {
    	$count_key = 'post_views_count';
    	$count = get_post_meta($postID, $count_key, true);
    	if($count==''){
    		$count = 0;
    			delete_post_meta($postID, $count_key);
    			add_post_meta($postID, $count_key, '0');
    	}else{
    		$count++;
    			update_post_meta($postID, $count_key, $count);
    	}
    }
Viendo 2 respuestas - de la 1 a la 2 (de un total de 2)
  • El debate ‘Substituir el meta de «fecha» por el meta de «views»’ está cerrado a nuevas respuestas.