How get the 10 most viewed pages (not post)

If you want to query pages you have to choose post_type=page – of course. Another “problem” is that the commen count isn’t exactly representing post/page views. If you really want page views – not comment count – try something like the function below – I got that from here: http://wpsnipp.com/index.php/functions-php/track-post-views-without-a-plugin-using-post-meta/. function getPostViews($postID){ $count_key = ‘post_views_count’; … Read more

Create custom post order (with custom post type meta)

Save your data in a single field as either YYYY-MM-DD or UNIXTIME. Then query like this: $args = array( ‘post_type’ => ‘POST_TYPE_NAME’, ‘meta_key’ => ‘date-key-name’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’, ); $query = new WP_Query( $args ); You should get an order, unless I am having a bad morning, of Day -> Month -> … Read more

Theme automatically inserting “more” tag on every post

In your archive.php file, you would want to replace this: <div class=”entry-content”> <?php colabs_custom_excerpt(); ?> <p class=”more”> <a href=”https://wordpress.stackexchange.com/questions/105195/<?php the_permalink() ?>”> <?php _e(“More”,”colabsthemes”); ?> </a> </p> With this <div class=”entry-content”> <?php the_excerpt(); // or the_content(); ?> </div><!– .entry-content –> The theme creator is MANUALLY inserting the more button (as you can see). You could just … Read more

Unable to convert all css and js features to WP theme

I prefer changing all: <?php bloginfo(‘template_url’); ?> and <?php bloginfo(‘stylesheet_directory’); ?> into: <?php echo get_template_directory_uri(); ?> For connection to default style.css I prefer to change: <link rel=”stylesheet” href=”https://wordpress.stackexchange.com/questions/105303/<?php bloginfo(“stylesheet_url’); ?>” type=”text/css”> into: <link rel=”stylesheet” type=”text/css” media=”all” href=”https://wordpress.stackexchange.com/questions/105303/<?php bloginfo(“stylesheet_url’ ); ?>” /> I found no script type is defined in any of the scripts: <script src=”https://wordpress.stackexchange.com/questions/105303/<?php … Read more

woocommerce breadcrump missing shop link [closed]

This can be done a lot easier. It is just necessary to change the permalinks settings accordingly – as mentioned on github at the issue 3145: Meet this criteria: // If permalinks contain the shop page in the URI prepend the breadcrumb with shop if ( $shop_page_id && strstr( $permalinks[‘product_base’], “https://wordpress.stackexchange.com/” . $shop_page->post_name ) && … Read more

enqueue script if page is not equal to

add_action( ‘wp_enqueue_scripts’, ‘ron_scripts’ ); function ron_scripts(){ if(is_home()){ wp_register_script( ‘homescript’, ‘/wp-content/themes/template/js/menu-home-open.js’ ); wp_enqueue_script( ‘homescript’ ); } else { wp_register_script( ‘nothomescript’, ‘/wp-content/themes/template/js/FILENAMEHERE.js’ ); wp_enqueue_script( ‘nothomescript’ ); } } alternatively replace is_home(); with any other method or code that determines what page you are on. ex: might work if(site_url() == get_permalink()){ //do home stuff } else { //do … Read more