New answers tagged

0

I noticed that the problem was related that one custom field was a taxonomy, so, as I was using the archive page for that custom post type, I only needed to filter the query looking for the date limits. $fecha_actual = current_time('Ymt'); //t regresa el ultimo día del mes $fecha_anterior = date('Ymd', strtotime("first day of last month")); ...


1

There's a couple things that you need to do to get the URL - you could combine them into one long sentence probably but I'll break it down. WordPress stores the thumbnail ID in the postmeta table as _thumbnail_id so we need to get that using get_post_meta(): $thumb_id = get_post_meta( $post->ID, '_thumbnail_id', true ); Now that we have the ID we need ...


2

You are correct, you will need to get the image URL and set is as a variable so you can echo it out as an inline style in your HTML. I've updated your foreach loop below and set the image as an inline style of your <li> element: foreach( $postQuery as $post ) : setup_postdata($post); if ( has_post_thumbnail() ) { ?> /* Get the post ...


0

So I finally figured it out. Using pre_get_posts and the $_GET global var to check if any query args have been added works a treat. I used the follow code to get the desired results. function my_pre_get_posts($query) { if( $query->is_main_query() && is_archive() && !isset($_GET['orderby']) && // ...


0

For this I use WP-CLI because I find it the easiest and it takes care of serialized data. wp search-replace 'http://example.dev' 'http://example.com' --skip-columns=guid There is also an option that writes your changes into an SQL file instead of manipulating the actual database: wp search-replace foo bar --export=database.sql


0

Try this function search_pre_get_posts( $query ) { if ( $query->is_search() && $query->is_main_query() ) { $currentdate = date('Y-m-d'); $enddate = strtotime(date('Y-m-d') . "+7 days"); $enddate = date('Y-m-d',$enddate); $query->set( 'meta_query', ...


0

Sorry guys, just found the solution: SELECT p.post_name, t.name as clientName FROM $wpdb->posts AS p INNER JOIN $wpdb->term_relationships AS tr ON ('p.ID' = tr.object_id) INNER JOIN $wpdb->term_taxonomy AS tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) INNER JOIN $wpdb->terms AS t ON (t.term_id = tt.term_id) WHERE p.post_status = ...


2

In each of your hooks & filters handlers, in addition to checking for archive conditions, check for a custom query var that you can then set for a custom/manual query. For example, where you might have: function wpse_223991_pre_get_posts( $wp_query ) { if ( $wp_query->is_main_query() && $wp_query->is_post_type_archive( 'my_post_type' ) ...


1

get_the_post_thumbnail() returns the full html output of the image, including the image <img /> tags. You want just the image src. Try this: <div class="leftBox"> <?php $query = new WP_Query( 'pagename=jour' ); // The Loop if ( $query && $query->have_posts() ) : while ( $query->have_posts() ) : ...


0

If you want to use WordPress you can download a custom post type plugin (such as Custom Post Type UI), create your Book post type; another plugin to generate your form for adding books (Gravity Forms + this looks good, or a similar solution, or create a form by hand). Then tweak the default WordPress search feature to search through Book post type only (you ...


1

Try this: $args = array( 'taxonomy' => 'post_tag', 'hide_empty' => 0 ); $tags = get_terms( $args ); $class_name = 'my-custom-class-name'; if ( ! empty( $tags ) && ! is_wp_error( $tags ) ) { shuffle( $tags ); foreach( array_slice( $tags, 0, 6 ) as $tag ) { printf( '<a class="%1$s" href="%2$s">%3$s</a>', ...


0

To get a specific post in WordPress, you can use the get_post() function and get_the_category() to get the categories associated with it. You can then use the code found in this answer to dump the SQL queries used: $GLOBALS['wpdb']->last_query.


0

You can do this by naming index of meta query, then passing array of these names in orderby parameter $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => '10', 'meta_query' => array( 'relation' => 'OR', 'with_time' => array( 'key' => 'TIME_meta_key', ...


1

I think I may have the solution below :) Try adding this to your CSS file: @media screen and (max-width: 479px) { .sow-slider-base ul.sow-slider-images li.sow-slider-image.sow-slider-image-cover { background-image: url('http://www.thousandgirlsinitiative.org/wp-content/uploads/2016/04/Wendy-mobile.jpg') !important; } ...



Top 50 recent answers are included