Custom archives page by month and year – nesting problem

After much more work, I developed a solution that outputs archives by year, month and day while minimising database calls. Posting it here for others to use: //* Add custom archives below entry content add_action( ‘genesis_entry_content’, ‘custom_archives_page_content’ ); function custom_archives_page_content() { global $post; // set post arguments $args = array( ‘posts_per_page’ => -1, ‘orderby’ => … Read more

Parse error: syntax error, unexpected ‘else’ (T_ELSE) [closed]

You aren’t ending your while before doing your else: $args = array( ‘post_type’ => ‘members_features’, ‘posts_per_page’ => 6 ); $the_query = new WP_Query( $args ); ?> <? if ( $the_query->have_posts() ) : ?> <? while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <h2><? the_title(); ?></h2> <div class=”entry-content”> <? the_content(); ?> </div> <? wp_reset_postdata(); ?> <?php /** … Read more

How to list all the posts in a personalized page? WordPress

There is a pretty simple way to query outside the loop using get_posts. Setting post_status => ‘any’ could net you all. The code below queries posts, pages and attachments. The loops through and outputs them all to an unordered list. $pages = get_posts( array( ‘post_type’ => ‘page’, ‘post_status’ => ‘any’, ‘numberposts’ => -1, )); $posts … Read more

Jquery autosave text area after typing

Am not sure what is your ID. Let as assume the ID as example Here is the code jQuery(function($) { $(‘#example’).on(‘keyup’, function() { if(autosave_timer) { clearTimeout(autosave_timer); } autosave_timer = setTimeout(save_by_ajax, 3000); // after 3 second of keyup save_by_ajax function will execute }); function save_by_ajax(){ var mid=$(this).attr(‘data’); var tid=’#’+mid; $(tid).jqte({“status” : false}); var content = $(tid).html(); … Read more

How to avoid timeout waiting for output from CGI script?

WordPress uses a file called wp-cron.php as a virtual cron job, or scheduled task in order to automate things like publishing scheduled posts, checking for plugin or theme updates, sending email notifications and more. By default WordPress is setup to call wp-cron.php everytime someone visits your WordPress website when a scheduled task is present, to … Read more

Call custom posttype outside the functions.php

Step-by-step: If you put everything in your functions.php or plugin file, it should work just fine. We need a user meta field, where User can decide if they want to activate a certain CPT. add_action( ‘show_user_profile’, ‘my_user_meta_show_faq’ ); add_action( ‘edit_user_profile’, ‘my_user_meta_show_faq’ ); add_action( ‘user_new_form’, ‘my_user_meta_show_faq’ ); function my_user_meta_show_faq( $user ) { $show_faq = get_user_meta($user->ID, ‘show_faq’, … Read more

Pagination 404 on my index.php

The reasons why you should not run query_posts() are perfectly outlined in this answer. Long story short: You overwrite the default query (that happens by WP core) and replace everything that was valid for this request with data that only matches for your secondary query. The function get_query_var() relies on the global $wp_query that gets … Read more

foreach all the post

Your code has many errors:- $thumbs isn’t used anywhere. $img_url = $thumb[‘url’]; undefined variable if(is_array($thumb) && $img_url) always false because of second point. $search_data = []; should be outside of loop. Check the correct part of code $search_data = []; if($query->have_posts()): while($query->have_posts()): $query->the_post(); $img_url = get_the_post_thumbnail_url(); if(!empty($img_url)){ $search_data[] = array( ‘name’ => get_the_title(), ‘thumb’ => … Read more