Ajax Dynamic Archives not showing correct results

this is what i ended up with which works nicely. functions.php part <?php function scripts_enqueue() { if(is_page(‘archives’)) { wp_enqueue_script(‘ajax_dropdown’, get_stylesheet_directory_uri() . ‘/js/loadposts.js’,array(‘jquery’)); wp_localize_script( ‘ajax_dropdown’, ‘myajax’, array(‘custom_nonce’ => wp_create_nonce(‘nonce-ajax-dropdown’), ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ) ) ); } } add_action( ‘wp_enqueue_scripts’, ‘scripts_enqueue’ ); function wp_ajax_load_posts(){ if(!wp_verify_nonce( $_GET[‘_wpnonce’], ‘nonce-ajax-dropdown’)) die( ‘Go away!’ ); $args = array( ‘year’ => … Read more

WordPress Custom Fields (Checkboxes with multiple values)

Under the premise, that your database entries do get saved correctly and your problem occurs on retrieval only: If multiple boxes had been selected, the values should live in the database as serialized arrays. Fortunately, get_post_meta unserializes them for us, but they are still arrays. Hence, your conditional should be modified like so: $program_flags = … Read more

How is a gallery associated with some post in database?

WordPress galleries are implemented as shortcodes: the shortcode should appear in the post_content of your “basic” post (whose post_type=”post”). The shortcode’s parameters specify the images to be included in the gallery by giving the post ID of the attachment-type post containing each image. So if you see two posts in wp_posts like this: id | … Read more

WordPress not opening posts with only numbers if permalink is post_name

Sorry I didn’t follow up on this. You mentioned you weren’t using date archives. You can change the date archive structure to remove the conflict with /%postname%/: function wpa_change_date_structure(){ global $wp_rewrite; $wp_rewrite->date_structure=”date/%year%/%monthnum%/%day%”; } add_action( ‘init’, ‘wpa_change_date_structure’ ); So now after permalinks are flushed, date archive URLs will be prefixed with date/, so numeric postnames will … Read more

If modified on same day, show only time

Give this a try: if(get_the_modified_date(‘zY’)==date(‘zY’)) { the_modified_date(‘g:i a’); } else { the_modified_date(‘F j, Y’); echo ‘ at ‘; the_modified_date(‘g:i a’); } It checks that the modified date is the current day. If it is, it only displays the modified time. Otherwise it displays both the date and time.

Get posts of ONE taxonomy term of custom post type

You can try making the $args array more specific with: $args = array( ‘post_type’ => ‘portfolio’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘locations’, ‘field’ => ‘slug’, ‘terms’ => ‘paris’ ) ) ); Grabbed this snippet similar to one on the WP Query page in the codex. Also, this is assuming that your custom post type … Read more

Get mixed category random posts

I whipped this up: echo ‘<ul>’; the_random_posts(); echo ‘</ul>’; /** * Send random posts to the browser (STDOUT). */ function the_random_posts() { // Use your own category ids. $random_posts = array_merge( get_random_posts( 31, 3 ), get_random_posts( 11, 1 ), get_random_posts( 24, 1 ) ); foreach ( $random_posts as $post ) { // Change this line … Read more

Ajax load more button in Recent posts widget

Look at WordPress’s documentation on AJAX In your theme or plugin, you’ll want to have code like: add_action(‘wp_ajax_my_load_recent’, ‘my_load_recent_posts’); add_action(‘wp_ajax_nopriv_my_load_recent’, ‘my_load_recent_posts’); function my_load_recent_posts() { $args = array( /* Arguments go here, i.e. how many posts to get */ ); query_posts($args); /* [1] */ /* Header wrap output */ if (have_posts()) : while (have_posts()) : the_post(); … Read more