how to use transient method?

First, you don’t need a raw SQL query, and by using one you give up all of WP’s optimisations. For example, if you run the query twice, it runs twice. If you had used WP_Query to getch those posts though, it would save them the first time to avoid making additional queries. It’s even possible … Read more

Pagination in category.php not functioning

if your aim is to restrict the category archive to your post_type ‘video’ and to 6 posts per page, do not edit category.php, rather use ‘pre_get_posts’ https://developer.wordpress.org/reference/hooks/pre_get_posts/ example code for your case: add_action( ‘pre_get_posts’, ‘category_post_type_video_custom’ ); function category_post_type_video_custom( $query ) { if ( ! is_admin() && $query->is_main_query() ) { // Not a query for an … Read more

Carousel slider with WP_Query to show 3 posts on each slide

Despite your question is a generic PHP programming problem, what you’re trying to do can be achieved like so, where the key is the $i which is a custom while counter: <div class=”carousel-inner” role=”listbox”> <?php if ( $popular_services->have_posts() ) : $i = 0; // add this counter while ( $popular_services->have_posts() ) : $popular_services->the_post(); ?> <?php … Read more

Getting Custom Field value in WP_Query

You need to define the $post global variable if you want to access its ID property: function excateg($categ) { global $post; $recent = new WP_Query(“cat=$categ&showposts=1”); while($recent->have_posts()){ $recent->the_post(); $imageurl = get_post_meta($post->ID, ‘post-img’, true); } } Use it after the_post() because that function will set up that variable. Alternatively you can use the $recent->post property instead of … Read more

Narrow Down a Shop Page Results Based on a Product Tag in WooCommerce

I passed query strings to the URL of the category page to display the tags within that category. This is what I did to solve the same problem function displayLocationDropdown() { if(!is_product_tag()){ $html=””; $html .= ‘<form class=”location-select” method=”post”>’; $html .= ‘<select id=”location-selector” name=”location” class=”location”>’; $tag = wp_tag_cloud( array( ‘format’ => ‘array’, ‘taxonomy’ => ‘product_tag’ ) … Read more

Renaming or Moving WP-Content Pros/Cons

I always recommend installing WordPress manually yourself. Some companies will insert a link crediting the hosting provider for the install. In the past, I’ve experienced 1-click installations that are not running the latest version of WordPress. In terms of migrating your website, you should follow this guide: http://codex.wordpress.org/Moving_WordPress. Smashing Magazine also provide an easy tutorial: … Read more

Related posts with WP_Query

parent is your answer here. Every term have a parent value set in its parent property. This value is an integer value, and represent the term id of its parent term. All top level terms have a value of 0 which just simply means it is a top level term First we need to build … Read more

No exposure on search engines

Please go to Settings > Reading or wp-admin/options-reading.php If it’s not unchecked it will not allow search engines to reach. For further modification information related to robots you can use the below plugin to modify robots.txt file: Plugin – Multipart robots.txt editor To see your robots.txt file you would visit the link as: http://www.example.com/robots.txt