Forum Replies Created

Viewing 15 replies - 16 through 30 (of 46 total)
  • Thread Starter vicetias

    (@vicetias)

    Or better migrate the views from a meta key called ‘post_views_count’. Is it possible?

    Thread Starter vicetias

    (@vicetias)

    Well, ok, don’t worry!

    Another question: I’m trying to get the post views without “.”. I mean 1.000 => 1000.

    What can I add to this code?

    update_post_meta( $postID, 'total_views', get_tptn_post_count_only( $postID, 'total' ) );
    update_post_meta( $postID, 'daily_views', get_tptn_post_count_only( $postID, 'daily' ) );

    And is there another period range to collect views? (weekly, monthly, yearly? I know there is a “custom period”, but I want to keep it to daily.

    I use this to save the views data to postmeta because I think it’s the only way to order the popular posts into a php archive. If there another way to do it without saving to postmeta, please let me know.

    This is the code:

    <?$pop_days = esc_html(get_option('mvp_pop_days')); $popular_days_ago = "$pop_days days ago"; $recent = new WP_Query(array( 'posts_per_page' => $mvp_related_num, 'orderby' => 'meta_value_num', 'order' => 'DESC', 'meta_key' => 'daily_views', 'date_query' => array( array( 'after' => $popular_days_ago )) )); while($recent->have_posts()) : $recent->the_post(); ?>

    • This reply was modified 5 years, 4 months ago by vicetias.
    • This reply was modified 5 years, 4 months ago by vicetias.
    • This reply was modified 5 years, 4 months ago by vicetias.
    • This reply was modified 5 years, 4 months ago by vicetias.
    • This reply was modified 5 years, 4 months ago by vicetias.
    • This reply was modified 5 years, 4 months ago by vicetias.
    Thread Starter vicetias

    (@vicetias)

    My support on Envato expired ?? but I don’t think the author could help because he doesn’t help to this kind of things.

    I found this inside the plugin if it helps:

    <?php
    namespace AutoLoadPosts;
    
    class Plugin
    {
    	public function Init()
    	{
    		add_action('plugins_loaded', array($this, 'LoadTextDomain'));
    		add_action('wp_enqueue_scripts', array($this, 'RegisterStyles'));
    		add_action('wp_enqueue_scripts', array($this, 'RegisterScripts'));
    		
    		$RelatedPostsWidget = new RelatedPostsWidget();
    		$RelatedPostsWidget->init();
    		
    //		$RentReceipt = new RentReceipt();
    //		$RentReceipt->Init();
    	}
    	
    	public function LoadTextDomain()
    	{
    		load_plugin_textdomain(ALP_PLUGIN_DOMAIN, false, ALP_PLUGIN_LANGUAGES_REL_PATH);
    	}
    	
    	public function RegisterStyles()
    	{
    		wp_enqueue_style('ql-jquery-ui', '//ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css');
    		wp_enqueue_style('ql-main', ALP_PLUGIN_STYLES_URL . 'main.css', array('ql-bootstrap', 'ql-jquery-ui'));
    	}
    	
    	public function RegisterScripts()
    	{
    		wp_enqueue_script('jquery');
    		wp_enqueue_script('jquery-ui-core');
    		
    		//wp_enqueue_script('jquery-history', ALP_PLUGIN_SCRIPTS_URL . 'jquery.history.js', array('jquery'), false, true);
    		wp_enqueue_script('jquery-sticky-kit', ALP_PLUGIN_SCRIPTS_URL . 'jquery.sticky-kit.min.js', array('jquery'), false, true);
    		wp_enqueue_script('jquery-waypoints', ALP_PLUGIN_SCRIPTS_URL . 'jquery.waypoints.min.js', array('jquery'), false, true);
    		
    		$data = array();
    		$data['ajaxurl'] = admin_url('admin-ajax.php');
    		$params = array(
    			'l10n_print_after' => 'alp_config = ' . json_encode($data) . ';'
    		);
    		
    	}
    }
    //jQuery(document).ready(function($) {
    jQuery(window).on('load', function() {
    	var $ = jQuery;
    	var nextPostFlag = false;
    	
    	if(!$('body').hasClass('single-post'))
    		return;
    	
    	if($('article').eq(0).length)
    		$('article').eq(0).addClass('first');
    	
    	createStickyWidgetArea();
    	
    	var $nextPost = $('.alp-related-post').eq(1);
    	if($nextPost.length)
    		$nextPost.addClass('load-next');
    	
    	createLastArticleWaypoint();
    	
    	$(window).on('scroll', findCurrentArticle);
    	$(window).on('resize', findCurrentArticle);
    	$(window).trigger('resize');
    	
    	function loadRelatedPosts()
    	{
    		if(nextPostFlag)
    			return;
    		
    		$nextPost = $('.alp-related-posts .alp-related-post.load-next');
    		if(!$nextPost.length)
    			return;
    		
    		//get next article
    		nextPostFlag = true;
    		$.get($nextPost.find('.post-title').attr('href'), {}, function(data) {
    			var postTitle=$(data).filter('title').text();
    			$nextPost.attr('data-document-title', postTitle);
    			var $newArticle = $(data).find('article');
    			if(!$newArticle.length)
    				return;
    			
    			if($('article#' + $newArticle.attr('id')).length)
    				return;
    			
    			$('article:last-of-type').after($newArticle);
    			
    			Waypoint.destroyAll();
    			$('.alp-related-post').removeClass('load-next');
    			
    			if($nextPost.next().length)
    				$nextPost.next().addClass('load-next');
    			
    			$('article img').load(function() {
    				createLastArticleWaypoint();
    				$(window).trigger('resize');
    				nextPostFlag = false;
    			});
    		}, 'html');
    	}
    	
    	function createStickyWidgetArea()
    	{
    		if(!$('.widget_alp-related-posts').length)
    			return;
    		$('.widget_alp-related-posts').stick_in_parent({
    			offset_top: 100,
    			recalc_every: 1,
    			bottoming: true
    		});
    	}
    	
    	function findCurrentArticle()
    	{
    		var windowTop = $(window).scrollTop();
    		var windowHeight = $(window).height();
    		var windowBottom = windowTop+windowHeight;
    		
    		var $article, 
    			articleTop, 
    			articleHeight, 
    			articleBottom,
    			$widgetPost,
    			advertHtml,
    			offset = 300;
    		
    		$('article').each(function() {
    			$article = $(this);
    			articleTop = $article.offset().top;
    			articleHeight = $article.height();
    			articleBottom = articleTop+articleHeight;
    			
    			if(articleTop-offset<windowTop && articleBottom-offset>windowTop && 
    				('post-'+$('.alp-related-post.current').attr('data-id'))!=$article.attr('id'))
    			{
    				$('.alp-related-post').removeClass('current');
    				$widgetPost = $('.alp-related-post.' + $article.attr('id'));
    				$widgetPost.addClass('current');
    				
    				advertHtml = $('.alp-related-posts .alp-advert')[0].outerHTML;
    				$('.alp-related-posts .alp-advert').remove();
    				$widgetPost.after(advertHtml);
    				
    				history.pushState(null, $widgetPost.attr('data-document-title'), $widgetPost.find('.post-title').attr('href'));
    				if($article.attr('pageview')!='1' && 
    					!$article.hasClass('first'))
    				{
    					var pageViewData={
    						hitType: 'pageview',
    						title: document.title,
    						page: location.pathname
    					};
    					//console.log('pageview');
    					//console.log(pageViewData);
    					ga('send', pageViewData);
    					$article.attr('pageview', 1)
    				}
    				
    				//$('.alp-related-post.' + $article.attr('id')).addClass('current');
    				
    				$('.alp-related-post').show();
    				$('.alp-related-post').each(function() {
    					if($(this).hasClass('current'))
    						return false;
    					$(this).hide();
    				});				
    				return false;
    			}
    		});
    	}
    	
    	function createLastArticleWaypoint()
    	{
    		var $lastArticle = $('article:last-of-type')[0];
    		var waypoint = new Waypoint({
    			element: $lastArticle,
    			handler: function(direction) {
    				loadRelatedPosts();
    			},
    			//offset: 'bottom-in-view'
    			offset: function() {				
    				//taken from waypoit.js 'bottom-in-view' function
    				return this.context.innerHeight() - this.adapter.outerHeight()+750;
    			}
    			//offset: '80%'
    		})
    	}
    	
    });
    

    If you want I can also send you the zip archive.

    • This reply was modified 5 years, 5 months ago by vicetias.
    • This reply was modified 5 years, 5 months ago by vicetias.
    • This reply was modified 5 years, 5 months ago by vicetias.
    Thread Starter vicetias

    (@vicetias)

    Actually the template has its own ALP plugin. This is the theme I am using.

    • This reply was modified 5 years, 5 months ago by vicetias.
    • This reply was modified 5 years, 5 months ago by vicetias.
    Thread Starter vicetias

    (@vicetias)

    Thank u so much, but I don’t know much about coding. That code goes in functions.php?

    • This reply was modified 5 years, 5 months ago by vicetias.
    Thread Starter vicetias

    (@vicetias)

    Ok, just found the right code and worked, but I can’t get views from day, week, month, year, just total. If I add ‘day’ into pvc_get_post_views doesn’t work.

    if ( !function_exists( 'PostViews' ) ) {
        function PostViews( $postID ) {
    
            // Get views count
            $count = pvc_get_post_views( $post_id );
    
            // Views meta key
            $count_key = 'post_views';
    
            // Save / update post meta
            update_post_meta( $postID, $count_key, $count );
    
        }
    }
    Thread Starter vicetias

    (@vicetias)

    Please @hcabrera, reply to my question at “How To: Sort a custom query by views”

    Thread Starter vicetias

    (@vicetias)

    I got it, thanks.

    Oh this is so good! I need this for last 12 and 6 hours, also 1 hour. Is it possible, Héctor?

    Thread Starter vicetias

    (@vicetias)

    Worked, thank you.

    Another question, ‘trending now’ in dashboard shows most viewed posts of the last 24 hours, right? And ‘most viewed’?

    • This reply was modified 7 years, 5 months ago by vicetias.
    • This reply was modified 7 years, 5 months ago by vicetias.
    Thread Starter vicetias

    (@vicetias)

    I forgot to check that, now the number is ok, thank you!

    Thread Starter vicetias

    (@vicetias)

    Acabo de percatarme de un problema con el contador. Tu plugin le pone un punto a los números cuando son miles, millones… y para que funcione esa meta key tiene que ser sin punto, por ejemplo: 1.015 debe ser 1015.

    ?Qué código debería a?adirle para quitarle los “.” a cada número?

    Thread Starter vicetias

    (@vicetias)

    Bueno, pensándolo bien usaré ambos widgets por separado, en realidad es bastante complicado lo que quiero. Y respondiendo a tu pregunta era solamente para integrar completamente el plugin al template, pero lo que más quería era modificar la función de las visitas y ya está logrado gracias a tu ayuda.

    And now in english lol, thank you so much and keep it up this amazing plugin, it’s the best!

    Thread Starter vicetias

    (@vicetias)

    Ok, así puedo explicarte mejor!

    Mira, lo que trato de decir es que quiero crear otro widget o modificar el que ya tiene mi tema. El código que te dejé más arriba es como el rango de tiempo “freshness” (en el que puedo elegir cualquier número de días para mostrar los posts populares) de tu plugin pero con otro código me imagino, entonces lo que necesito es a?adir la forma normal de tiempo de WPP, el que muestra por defecto los posts más populares sin importar la fecha en que fueron publicados!

    Estas dos opciones que incluye tu plugin necesito a?adir al archivo php.

    null

    No sé si funcione pero sé de algunos templates como bimber que incorporaron totalmente el plugin pero con nuevos archivos de widget, funciones, pero eso es muy complicado para mí, yo sólo necesito a?adirle la data de los rangos de tiempo del plugin.

    Lo de la función que te pedí está perfecta, está integrada y ahora cuenta las visitas desde tu plugin, por lo que post_views_count es vital para mi tema. Ahora solo me falta lo otro que espero hayas entendido. Gracias.

    • This reply was modified 7 years, 8 months ago by vicetias.
    • This reply was modified 7 years, 8 months ago by vicetias.
    • This reply was modified 7 years, 8 months ago by vicetias.
    Thread Starter vicetias

    (@vicetias)

    Trying to modify that widget with the range data from your plugin (post-views-count is already with it) in especially this:

    <?php $popular_days_ago = "$popular_days days ago"; $recent = new WP_Query(array( 'posts_per_page' => $number, 'orderby' => 'meta_value_num', 'order' => 'DESC', 'meta_key' => 'post_views_count', 'date_query' => array( array( 'after' => $popular_days_ago )) )); while($recent->have_posts()) : $recent->the_post(); ?>

    It’s like the freshness of your plugin but I need the default way (time range)

Viewing 15 replies - 16 through 30 (of 46 total)