vicetias
Forum Replies Created
-
Forum: Plugins
In reply to: [WordPress Popular Posts] Post metaMy bad sorry, just checked again and it take a bit to update but the views are now synchronized! Thanks!
And now, popular widget of my theme has the “freshness” filter you have on your plugin but if is possible, I need to add the default range too (no matter the date a post was published, you know).
If you can help me with this, I’ll be totally grateful.
This is the code:
<?php /** * Plugin Name: Popular Posts Widget */ add_action( 'widgets_init', 'mvp_pop_load_widgets' ); function mvp_pop_load_widgets() { register_widget( 'mvp_pop_widget' ); } class mvp_pop_widget extends WP_Widget { /** * Widget setup. */ function mvp_pop_widget() { /* Widget settings. */ $widget_ops = array( 'classname' => 'mvp_pop_widget', 'description' => esc_html__('A widget that displays a list of popular posts within a time period of your choice.', 'click-mag') ); /* Widget control settings. */ $control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => 'mvp_pop_widget' ); /* Create the widget. */ $this->__construct( 'mvp_pop_widget', esc_html__('Click Mag: Popular Posts Widget', 'click-mag'), $widget_ops, $control_ops ); } /** * How to display the widget on the screen. */ function widget( $args, $instance ) { extract( $args ); /* Our variables from the widget settings. */ global $post; $title = apply_filters('widget_title', $instance['title'] ); $popular_days = $instance['popular_days']; $number = $instance['number']; /* Before widget (defined by themes). */ echo $before_widget; /* Display the widget title if one was input (before and after defined by themes). */ if ( $title ) echo $before_title . $title . $after_title; ?> <div class="mvp-trend-widget-wrap left relative"> <?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(); ?> <div class="mvp-trend-widget-story left relative"> <?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) { ?> <div class="mvp-100img-out right relative"> <a href="<?php the_permalink(); ?>" rel="bookmark"> <div class="mvp-trend-widget-img left relative"> <?php the_post_thumbnail('mvp-small-thumb'); ?> </div><!--mvp-trend-widget-img--> </a> <div class="mvp-100img-in"> <div class="mvp-trend-widget-text left relative"> <h3 class="mvp-main-blog-cat left"><span class="mvp-main-blog-cat left"><?php $category = get_the_category(); echo esc_html( $category[0]->cat_name ); ?></span></h3> <a href="<?php the_permalink(); ?>" rel="bookmark"><h2><?php the_title(); ?></h2></a> </div><!--mvp-trend-widget-text--> </div><!--mvp-100img-in--> <div class="mvp-story-share-wrap"> <span class="mvp-story-share-but fa fa-share fa-2"></span> <div class="mvp-story-share-cont"> <a href="#" onclick="window.open('https://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php the_title(); ?>', 'facebookShare', 'width=626,height=436'); return false;" title="Share on Facebook"><span class="mvp-story-share-fb fa fa-facebook fa-2"></span></a> <a href="#" onclick="window.open('https://twitter.com/share?text=<?php the_title(); ?> -&url=<?php the_permalink() ?>', 'twitterShare', 'width=626,height=436'); return false;" title="Tweet This Post"><span class="mvp-story-share-twit fa fa-twitter fa-2"></span></a> <a href="#" onclick="window.open('https://pinterest.com/pin/create/button/?url=<?php the_permalink();?>&media=<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'post-thumb' ); echo esc_url( $thumb['0'] ); ?>&description=<?php the_title(); ?>', 'pinterestShare', 'width=750,height=350'); return false;" title="Pin This Post"><span class="mvp-story-share-pin fa fa-pinterest-p fa-2"></span></a> </div><!--mvp-story-share-cont--> </div><!--mvp-story-share-wrap--> </div><!--mvp-100img-out--> <?php } else { ?> <div class="mvp-trend-widget-text left relative"> <h3 class="mvp-main-blog-cat left"><span class="mvp-main-blog-cat left"><?php $category = get_the_category(); echo esc_html( $category[0]->cat_name ); ?></span></h3> <a href="<?php the_permalink(); ?>" rel="bookmark"><h2><?php the_title(); ?></h2></a> </div><!--mvp-trend-widget-text--> <?php } ?> </div><!--mvp-trend-widget-story--> <?php endwhile; wp_reset_postdata(); ?> </div><!--mvp-trend-widget-wrap--> <?php /* After widget (defined by themes). */ echo $after_widget; } /** * Update the widget settings. */ function update( $new_instance, $old_instance ) { $instance = $old_instance; /* Strip tags for title and name to remove HTML (important for text inputs). */ $instance['title'] = strip_tags( $new_instance['title'] ); $instance['popular_days'] = strip_tags( $new_instance['popular_days'] ); $instance['number'] = strip_tags( $new_instance['number'] ); return $instance; } function form( $instance ) { /* Set up some default widget settings. */ $defaults = array( 'title' => 'Title', 'number' => 5, 'popular_days' => 30 ); $instance = wp_parse_args( (array) $instance, $defaults ); ?> <!-- Widget Title: Text Input --> <p> <label for="<?php echo $this->get_field_id( 'title' ); ?>">Title:</label> <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:90%;" /> </p> <!-- Number of days --> <p> <label for="<?php echo $this->get_field_id( 'popular_days' ); ?>">Number of days to use for Popular Posts:</label> <input id="<?php echo $this->get_field_id( 'popular_days' ); ?>" name="<?php echo $this->get_field_name( 'popular_days' ); ?>" value="<?php echo $instance['popular_days']; ?>" size="3" /> </p> <!-- Number of posts --> <p> <label for="<?php echo $this->get_field_id( 'number' ); ?>">Number of posts to display:</label> <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" value="<?php echo $instance['number']; ?>" size="3" /> </p> <?php } } ?>
Forum: Plugins
In reply to: [WordPress Popular Posts] Post metaOk ok, thank you so much!! (pero odio un poco el inglés y no sé mucho hablarlo, así trataré de escribir en spanglish jaja)
Sabes, no dio error el código, pero se quedan atascadas algunas y no cuenta las nuevas visitas, creo que se demora más de la cuenta porque comparo las estadísticas del plugin con post_views_count y siempre está por debajo :/
- This reply was modified 7 years, 4 months ago by vicetias.
Forum: Plugins
In reply to: [NextScripts: Social Networks Auto-Poster] Facebook not workingI still get the same error and I just added some text to the message format field… With Twitter is all ok but FB didn’t work anymore.
Forum: Plugins
In reply to: [NextScripts: Social Networks Auto-Poster] Facebook not workingOk but before I posted many times with that field empty, plus I added text on it too without problems. Now I added text again (%EXCERPT%) and still get the error.
- This reply was modified 7 years, 6 months ago by vicetias.
Forum: Plugins
In reply to: [Toplytics] Post viewsThanks, I got it with the JS code you provided, I used an unique ID and all is ok, the only thing I can’t get is the post thumbnail of every link like in the widget.
I tried with that php code too and for me it loads faster than the JS code (but you say that’s better). I putted div tags and it looks good but the only thing I need is delete the number before the link, I tried deleting echo (++$k) . ‘) but I got error. What I need to delete?
if ( $toplytics_results ) { $k = 0; foreach ( $toplytics_results as $post_id => $post_views ) { echo (++$k) . ')
- This reply was modified 7 years, 10 months ago by vicetias.
Forum: Plugins
In reply to: [Toplytics] Post viewsI can’t ?? I need to keep this:
<?php /* Template Name: Popular */ ?> <?php get_header(); ?>
I added the code into the “scripts” tags but nothing appears and the only type of code that works is this but with the default look (see the screenshoot above):
<?php if ( function_exists( 'toplytics_get_results' ) ) { $toplytics_args = array( 'period' => 'year', // default=month (today/week/month) 'numberposts' => 100 // default=5 (min=1/max=250) ); $toplytics_results = toplytics_get_results( $toplytics_args ); if ( $toplytics_results ) { $k = 0; foreach ( $toplytics_results as $post_id => $post_views ) { echo (++$k) . ') <a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . get_the_title( $post_id ) . '</a> - ' . $post_views . ' Views<br />'; } } } ?>
The only I should need is adding css style like I did in template.php but apparently is imposible. Any way to do that?
Forum: Plugins
In reply to: [Toplytics] Post viewsThank you for your support! Google Analytics Post Pageviews didn’t work anymore at least for me.
I tried with the codes you provided on ‘Faq’ and it shows the default look in a php template (i can’t add div class on it), unlike the widget because I added css style and looks like this:
And now, that code (https://github.com/PressLabs/toplytics/blob/master/toplytics/js/toplytics.js) where I must put it? In functions? Sorry I don’t know nothing about JS and I think i’m still need a php file because these pages have a template name: ‘home’, ‘latest’ in order to show it properly, then I created ‘popular’ template
<?php /* Template Name: Populares */ ?> <?php get_header(); ?>
Forum: Plugins
In reply to: [Toplytics] Add new features pleaseLooking good I think! https://tendencilandia.com/toplytics.json
And now it’s working properly, maybe because I removed the ‘year’ range? I don’t know but I checked my popular posts from today and is synced well with the plugin.
You could try adding the year range and all time in a upcoming update? It would be amazing. Thanks.
Forum: Plugins
In reply to: [Toplytics] Add new features please1 hour? but mine is not updated since yesterday :/ i don’t understand because few days ago was working and updated properly with the time range: today.
Anyway thanks for the replies and for the plugin, keep it up!
Forum: Plugins
In reply to: [Toplytics] Add new features pleaseIt’s delayed and not updated in real time
Forum: Plugins
In reply to: [Toplytics] Add new features pleaseOk, and you noticed that popular posts of the last day are not updated properly? it takes a bit of time, actually my popular posts are same as yesterday and they’ve changed today according to GA, what’s wrong with that?
Forum: Plugins
In reply to: [Toplytics] Add new features pleaseOh thank u! Look, I better modified toplytics.php and added year range:
public function add_ranges() { $ranges = array( 'year' => date_i18n( 'Y-m-d', strtotime( '-364 days' ) ), 'month' => date_i18n( 'Y-m-d', strtotime( '-29 days' ) ), 'week' => date_i18n( 'Y-m-d', strtotime( '-6 days' ) ), 'today' => date_i18n( 'Y-m-d', strtotime( 'today' ) ), ); $this->ranges = apply_filters( 'toplytics_ranges', $ranges ); }
It works properly too! I don’t want to add another php file in the plugin folder so I wanted to do so. For all time could be like this:?
'all time' => date_i18n( 'Y-m-d', strtotime( '-9999 days' ) ),
And can you tell me how would be in a certain time? For example after January 1st or between monday and friday?
And the last one, I saw the faq and tried to use the plugin outside the sidebar and works but not with my own css style like in the widget (I modified the template.php file too!)
I used this code:
<?php if ( function_exists( 'toplytics_get_results' ) ) { $toplytics_args = array( 'period' => 'month', // default=month (today/week/month) 'numberposts' => 3 // default=5 (min=1/max=250) ); $toplytics_results = toplytics_get_results( $toplytics_args ); if ( $toplytics_results ) { $k = 0; foreach ( $toplytics_results as $post_id => $post_views ) { echo (++$k) . ') <a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . get_the_title( $post_id ) . '</a> - ' . $post_views . ' Views<br />'; } } } ?>
- This reply was modified 7 years, 10 months ago by vicetias.
Forum: Plugins
In reply to: [Toplytics] Add new features pleaseOk, thank you but i don’t know how github works :/ and i tried to use the filter toplytics_ranges time ago but didn’t work, plus i don’t know where i must put the code properly
Forum: Plugins
In reply to: [Yoast SEO] Twitter boxTwitter card meta is enabled. Keyword analysis and readability analysis are disabled because i don’t need those features but if i enable one, Twitter appears.
Forum: Plugins
In reply to: [Toplytics] Cant link my GA accountResolved! I put some div class on the template file of your plugin and the widget looks exactly like my theme, the only thing I need now is make a numbered list of the popular posts, please help me, I don’t understand how works counter increment.
- This reply was modified 7 years, 11 months ago by vicetias.