Custom Select Query – Selecting the Year?
Don’t use the direct SQL query, there’s no point and it’s bad practice. Instead use WP_Query: $year = date(‘Y’); $query = new WP_Query( array( ‘year’ => $year, ‘post_type’ => ‘news’ ) );
Don’t use the direct SQL query, there’s no point and it’s bad practice. Instead use WP_Query: $year = date(‘Y’); $query = new WP_Query( array( ‘year’ => $year, ‘post_type’ => ‘news’ ) );
This should help you.. <?php function remove_images( $content ) { //Run only on the front page, in your case the homepage if(is_front_page()) { //Remove the images $postOutput = preg_replace(‘/<img\b[^>]++>/i’,”, $content); //Get the first 200 characters only, you can change the number if you want $postOutput = wp_html_excerpt($postOutput, 200); return $postOutput; } return $content; } add_filter( … Read more
If you check the code for previous_posts_link function in link-template.php file i.e. function previous_posts_link( $label = null ) { echo get_previous_posts_link( $label ); } // get_previous_posts_link function get_previous_posts_link( $label = null ) { global $paged; if ( null === $label ) $label = __( ‘« Previous Page’ ); if ( !is_single() && $paged > 1 … Read more
Did you mean this? Menus –> Select an Category –> Add to Menu. Click Save! The link to this page should be available on your menu!
I don’t know exactly how your code works BUT I do know this. If you only have one loop on the page-template you could use query_posts(); but if you have more than 1 loop it will screw up the code, even if you reset it. I would recommend you to use WP_Query like this: <?php … Read more
Scenario 1: AUTO First of all, you need to get full database from phpMyAdmin. Basics come with _posts and _postmeta, but you probably need full data with categories, taxonomies, comments etc. that may have been affected in 1 evening. I would suggest to export WHOLE database to .sql file and then import it to new … Read more
Your Home Page is displayed with index.php or front-page.php in WordPress. PLAN B: First of all, you have to create a category for Technical Notes page (i.e.: Category Name = “Technical Notes”). Now the plan is, all the posts, by default will be displayed on the homepage by default (as it is doing now), excluding … Read more
well, you must understand what “category” is and what a “post” is … you can imagine WP as a collection of posts . those “POSTS” are put inside “CATEGORIES” like books in a library .. The Categories are only for classification reasons. By themselves they are nothing. now , the “categories” page in wordpress, is … Read more
First you need to create that custom field and choose an apropriate name, then you can paste your link and save the post. After that, you must open your single.php file (or the file where you want the link to exist) and insert the following inside the loop: <?php //first i select which custom field … Read more
Here is some code I drafted up. It may not be using the best practices or even work for the matter of fact, as I have not tested it, but theoretically it should work. 🙂 <?php /** * Retrieve the closest post from a set time from today. * * @param integer $daysago the number … Read more