Tokant
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Sort posts by "Popular" – What is wrong with this code?The WordPress documentation states that showposts is deprecated:
https://codex.www.ads-software.com/Class_Reference/WP_Query#Pagination_Parameters.And days is not a parameter.
Forum: Fixing WordPress
In reply to: Sort posts by "Popular" – What is wrong with this code?I use this in my functions.php:
function wpb_set_post_views($postID) { $count_key = 'wpb_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); } } //To keep the count accurate, lets get rid of prefetching remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); function wpb_track_post_views ($post_id) { if ( !is_single() ) return; if ( empty ( $post_id) ) { global $post; $post_id = $post->ID; } wpb_set_post_views($post_id); } add_action( 'wp_head', 'wpb_track_post_views');
Then to retrieve the 6 most popular posts i use:
<?php $args = array( 'posts_per_page' => 6, 'meta_key' => 'wpb_post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC' ); $query = new WP_Query( $args ); if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>
As you can see the function uses wpb_post_views_count, while you use _count-views_all, so it should work. However, you are using ‘showposts’ instead of ‘posts_per_page’. Maybe that is the problem?
Forum: Fixing WordPress
In reply to: Export post_tags from database tablei know how to select the post_tags:
SELECT * FROM wp_terms wt INNER JOIN wp_term_taxonomy wtt ON wt.term_id = wtt.term_id WHERE wtt.taxonomy = 'post_tag' AND wtt.count >1 LIMIT 0 , 500
But how do i export them and import them correctly?
To make it easier, i would like to add that the two tables run on the same database.
Forum: Fixing WordPress
In reply to: Custom WalkerSo basically, i need to put this code
<div class="dropdown outer"> <div class="inner"> <section class="m-grid m-grid--divide-6 l-grid--divide-6"> <div class="grid_unit l-grid_unit--span-2"> <article class="list"> <p>Child categories:</p>
between:
<a href="">Parent category</a>
and the sub-menu with child categories:
<ul class="sub-menu"> <li><a href="">Child category 1</a></li> <li><a href="">Child category 2</a></li> <li><a href="">Child category 3</a></li> </ul>
and then add this after the sub-menu:
</article> </div> <div class="grid_unit"> <article class="box"> <article class="image"><img src=""></article> <article class="excerpt small"><span class="category">Category 1</span><a href="">The title</a></article> </article> </div> <div class="grid_unit"> <article class="box"> <article class="image"><img src=""></article> <article class="excerpt small"><span class="category">Category 2</span><a href="">The title</a></article> </article> </div> <div class="grid_unit"> <article class="box"> <article class="image"><img src=""></article> <article class="excerpt small"><span class="category">Category 1</span><a href="">The title</a></article> </article> </div> <div class="grid_unit"> <article class="box"> <article class="image"><img src=""></article> <article class="excerpt small"><span class="category">Category 2</span><a href="">The title</a></article> </article> </div> </section> </div> </div>
Forum: Fixing WordPress
In reply to: Weekly archive and paginationBut how do i create pagination that can show previous and next weeks?
Forum: Fixing WordPress
In reply to: Weekly archive and paginationWith query_posts:
$current_year = date('Y'); $current_week = date('w'); $args = array( 'year' => $current_year, 'w' => $current_week, 'posts_per_page' => -1, 'nopaging' => true, 'order' => 'ASC' ); query_posts( $args );
Forum: Fixing WordPress
In reply to: Post has disappeared but is still in admin areaAre you shown a 404 page?
Forum: Fixing WordPress
In reply to: Displaying all posts as thumbnailsIf you want the 6 contentblocks (thumbnail and title) to be horizontally aligned, set the css display property of the contentblocks to inline or inline-block.
More info here: https://www.w3schools.com/cssref/pr_class_display.asp
Or you could use a table to give the blocks equal width:
https://cssdesk.com/Nkt7aOr you could use a fluid layout system, which is a bit more complex.
Forum: Fixing WordPress
In reply to: Help!Have you installed WordPress in a subdirectory?
Forum: Fixing WordPress
In reply to: Adding custom fields other than title and content on pagesI would suggest using the Advanced Custom Fields plugin and use that to setup all the extra content-boxes you need. ACF have a well-written documentation:
https://www.advancedcustomfields.com/resources/Forum: Fixing WordPress
In reply to: Post has disappeared but is still in admin areaWhen you edit the post and click “Preview”, doesn’t it show the post in the frontend?
Forum: Fixing WordPress
In reply to: Weekly archive and paginationI found a solution for my first problem.
With WP_Query:
<?php $week = date('W'); $year = date('Y'); $args=array( 'w'=> $week, 'year'=> $year, 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => -1, 'caller_get_posts'=> 1 ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { echo 'List of Posts for year '.$year . ' week '.$week; while ($my_query->have_posts()) : $my_query->the_post(); ?> <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p> <?php endwhile; } wp_reset_query(); // Restore global post data stomped by the_post(). ?>
With get_posts:
/* Help the query to create pagination */ $limit = get_option('posts_per_page'); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; /* Grab this week number of a year (ISO-8601) */ $thisWeek = date('W'); /* Start to query! */ $currentPosts = query_posts('showposts=' . $limit . '&paged=' . $paged . '&w='.$thisWeek);
Forum: Fixing WordPress
In reply to: Making a custom backgroundTry adding this before the html and body tags in your style.css-file:
* { background:none !important; }
Forum: Fixing WordPress
In reply to: DNSTopic resolved.
Forum: Fixing WordPress
In reply to: DNSA webforward was my first suggestion too and what i am still trying to convince my client to do. With your information to back it up, i have a stronger case ??
Have a nice weekend and thanks for taking time to respond!