Make homepage the newest post of a custom post type

Create a front-page.php file in the theme and query for the latest post of your post type. $args = array( ‘post_type’ => ‘yourtypename’, ‘posts_per_page’ => 1, ‘ignore_sticky_posts’ => true, ‘post_status’ => ‘publish’, } $latest = new WP_Query($args); if ($latest->have_posts()) { while ($latest->have_posts()) { $latest->the_post(); the_title(); // etc } } See the Template Hierarchy for information … Read more

How to Display Posts From Category Within a Custom Taxonomy?

@Krzysiek answer above didn’t work because have_posts is a method not a property. It should be have_posts() not have_posts. Here’s the corrected code: $my_query = new WP_Query( array( ‘post_type’=>’news’, ‘posts_per_page’=>4, ‘tax_query’=>array( array( ‘taxonomy’=>’instituteName’, ‘field’=>’slug’, ‘terms’=>’businessschool’ // change to real slug ) ) ) ); while ( $my_query->have_posts() ) { $my_query->the_post(); // display post }

$wpdb->get_col and ORDER BY?

You don’t want ORDER BY $wpdb->postmeta.post_id rand(). If you had debugging enabled, you’d see an error. You need to separate ORDER BY values with a comma– ORDER BY $wpdb->postmeta.post_id, rand(). In your case, that won’t do any good because the first value gets precedence, so the query will order by the ID and then randomize … Read more

custom post type archive page has 404 error even though has_archive is true

So it turns out that when the CPT was registered, the following was used in the “rewrite” argument in register_post_type: rewrite => “recipes/%tax_rec_cat%” I don’t know the intention of this, I suppose whoever wrote it thought it was necessary to include both that and the custom_links function I posted in the original question in order … Read more

Strip Characters From Tag Name

Here it how you can do it. $tag = ‘medical &amp; health’; $tag_class = preg_replace(‘/[^A-Za-z0-9-]+/’, ‘-‘, html_entity_decode($tag)); echo ‘<li><a class=”‘.$tag_class.'” href=”https://wordpress.stackexchange.com/questions/108491/javascript:void(0)”>’ .$tag. ‘.</a></li>’;

Delete a custom post function value

Your function is checking to see if anything “is set” before proceeding to update, and also that it isn’t an empty string. Remove the “if” portions of your update statements, or better yet, put an “else” after to delete post meta if it is empty. Example: if ( isset( $_POST[‘games_database_game_release’] ) && $_POST[‘games_database_game_release’] != ” … Read more

Make custom post meta sortable front end

You can define a simle anchor tag for each table heading, having it’s own seperate id, then you have to use onclick event for each heading, depending upon the id which sends an ajaxrequest to get the results sorted in corresponding order. with the respective results you can replace the content of parent div with … Read more

Why content coming from single?

Here is solution…please try this stuff…… <?php /** * The template for displaying all pages. * * This is the template that displays all pages by default. * Please note that this is the WordPress construct of pages * and that other ‘pages’ on your WordPress site will use a * different template. * * … Read more