Force redirect single.php to index
put this code in functions.php file add_action(‘wp’, ‘myfun’); function myfun(){ if(is_single()){ wp_redirect( home_url() ); exit; } } hope this trick solve your problem. all the best 😉
put this code in functions.php file add_action(‘wp’, ‘myfun’); function myfun(){ if(is_single()){ wp_redirect( home_url() ); exit; } } hope this trick solve your problem. all the best 😉
init is too early (it happens before the main query), use the action template_redirect instead. And for the ID use get_the_ID(). Example: if ( is_singular() ) setcookie( get_the_ID(), ‘visited’,time() + ( DAY_IN_SECONDS * 31 ) );
Per a comment, the problem was due to the use of query_posts which clobbers the main query. Please don’t use query_posts. It should be noted that using this to replace the main query on a page can increase page loading times, in worst case scenarios more than doubling the amount of work needed or more. … Read more
is_single() and is_page() refer to the main query and as far as I know are not altered to match the individual posts in a Loop. They refer to the type of page not to the individual posts. Try and you should see what I mean: $data = array(); $args = array( ‘posts_per_page’ => ‘-1’, ‘post_type’ … Read more
Add <!–nextpage–> in your post editor to split your post.
Save yourself a loop with get_posts and ‘fields’ => ‘ids’. // Default Query function do_query($args = null) { $default_args = array( ‘numberposts’ => -1, ‘posts_per_page’ => -1, ‘post_status’ => ‘publish’, ‘fields’ => ‘ids’, ); if (null !== $args && !empty($args)) $args = array_merge($default_args, $args); else $args = $default_args; return get_posts($args); } // Customize Query $post_ids … Read more
Queries ofcourse. It’s faster… But in this case just please delete you wp site and start with something faster… here is my superfast framework for you… <?php /*Your bunny wrote */ I did tests, 0.0000001 runtime vs WP usually 0.7-2.8 Sarcasm off P/S/ This question have no sence since using direct queries and output of … Read more
You will need to add %link to the first parameter ($format) of next_post_link and previous_post_link This will generate the html links to the respective posts EDIT 1 Just on your statement about custom queries, did you had a look at how pre_get_posts can be used to alter the main query as needed. It is never … Read more
What about using: echo get_the_term_list( $post->ID, ‘artist-genre’, ‘<li>’, ‘,</li><li>’, ‘</li>’ ); instead, to generate the HTML list? Or simply: the_terms( $post->ID, ‘artist-genre’, ‘<li>’, ‘,</li><li>’, ‘</li>’ ); that’s a wrapper for get_the_term_list(). Also notice that you’re missing the is_wp_error() check, in your code snippet, because wp_get_post_terms() can return the WP_Error object, for an unknown taxonomy. But … Read more
get_the_content and the_author have to be in a loop so you would need to use other functions to get the content you need global $wp_query; $post = $wp_query->post; $page_id = $post->ID; // page ID $page_object = get_page( $page_id ); // page stuff $author_id = $post->post_author; // author ID $page_content = $page_object->post_content; $author_name = get_the_author_meta( ‘display_name’, … Read more