Forum Replies Created

Viewing 15 replies - 61 through 75 (of 92 total)
  • Thread Starter ageingdj

    (@ageingdj)

    Hi there,
    Thanks for all your help.
    (Although this means I’ll never be able to follow the original tutorial!)
    Paul

    Thread Starter ageingdj

    (@ageingdj)

    Hi there,
    The last post was more for me (being a bit thick and needed to spell everything out).
    Anyhow, I added the php brackets to your code and it works a dream and just (just!) needs styling and some kind of filter (a dropdown/radio button list of categories).

    Many thanks

    PS On a bit of a tangent, ACF has a “Relationship” field type which allows to filter on Post Type and/or Taxonomy. I have put one on my back-end called “rel_field” but have no idea what to do with it (I googled it & it seems quite a common problem).

    Thread Starter ageingdj

    (@ageingdj)

    Hi there,
    Thanks for your reply.
    I was following a [beginners] tutorial on using php & ACF to create a page template and this line of code appeared with no explanation over what is was, what it did or wether I needed it or not – totally confusing!
    (I keep getting a blank screen whether I use this code or not)

    Many thanks

    Thread Starter ageingdj

    (@ageingdj)

    Hi,
    I’ve just gone through your code and worked out what it’s doing (I should have this first)- it’s showing the fields I select in the loop output for every record in the selected cat_id * the number of records in that category!
    Anyhow the loops evolved and starting to look almost ok:

    >>>>

    // Updated loop output code
    if ($loop->have_posts()) :
    while ($loop->have_posts()): $loop->the_post(); ?>
    <h2><?php the_post_thumbnail('thumbnail'); the_title(); ?></h2>
    <?php endwhile;
    else : 
    echo 'Query failed to find posts matching the criteria <br>';
    endif;
    endforeach;
    Thread Starter ageingdj

    (@ageingdj)

    Hi there,
    Interesting
    The code below returns the below dates twelve times (there 12 records in cat 112) if I change the tax_id to 114 (8 records) I get these dates repeated 8 times.`
    “January 5, 2018
    December 23, 2017” (I haven’t figured out what these dates are yet).

    But if I change the code to: <h2><?php the_title(); ?></h2> I get every title (regardless of the category) times by the number of records in the selected category!
    Wierd

    <?php
    global $wpdb, $post;
    $query = $wpdb->get_results( "SELECT * FROM $wpdb->posts
        LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)
        WHERE $wpdb->term_relationships.term_taxonomy_id = 112
        AND $wpdb->posts.post_type = 'download'
        AND $wpdb->posts.post_status = 'publish'
        GROUP BY $wpdb->posts.ID
        ORDER BY $wpdb->posts.post_date DESC;" );
    if ( $query ) {
        foreach ( $query as $post ) :
    	setup_postdata( $post );
    
            // Your usual loop output code goes here
    if ($loop->have_posts()) :
    while ($loop->have_posts()): $loop->the_post(); ?>
    <h2><?php the_date(); ?></h2>
    <?php endwhile;
    else : 
    echo 'Query failed to find posts matching the criteria <br>';
    
    endif;
        endforeach;
    }
    ?>
    Thread Starter ageingdj

    (@ageingdj)

    Hi there,
    Sorry, it didn’t work:
    SELECT * FROM $wpdb->posts = Titles only,
    SELECT $wpdb->posts.* = Titles only,
    SELECT *.* = Blank page.

    As for the rest, you’ve lost me!
    Does the code go after the Select close bracket?
    If so, nothing seems to work for the loop output .

    Thread Starter ageingdj

    (@ageingdj)

    Hi,
    All hail SQL!
    It worked. Just to check I added
    OR $wpdb->term_relationships.term_taxonomy_id = 106
    and it returned everything from both categories:
    /——————- Ally Pally Full Set
    Ally_View5
    Ally_Trees1
    Ally_Trees2
    Ally_View1
    …….
    Thames Stones 04
    Thames Stones Set of 4
    Thames Stones 03
    Thames Stones 02
    Thames Stones 01
    But I can’t figure out what the names of the other fields.

    Thread Starter ageingdj

    (@ageingdj)

    Hi,
    I made a complete horlicks of it and ended up getting my host to restore Sunday’s copy – so I don’t fancy doing that again!.
    (It turns out I have “auto update” active and the system files get updated automatically).
    Anyway, I’ve tried a couple of things:
    I tried the EDD shortcode [downloads category="112"] to prove that category 112 exists which worked.
    Then I tried a simple loop on normal posts to prove there’s nothing on my pc stopping the loop from working:

     // The Query
    	  query_posts( array ( 'cat => 110', 'posts_per_page' => -1 ) );
     	  // The Loop
    	 while ( have_posts() ) : the_post(); ?>
    	    <li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
     	  <?php endwhile;
     	  // Reset Query
    	  wp_reset_query();

    Which worked a treat.
    Which seems to prove it’s the combination of the loop and custom post that’s the problem, could it not be a tax-query (although I’ve not got one to work)?

    $args = array(
        'post_type' => 'edd_download',
        'tax_query' => array(
            array(
                'taxonomy' => 'category',
                'field' => 'slug',
                'terms' => 'allypallly',
      )    ) );
    $query = new WP_Query( $args );
    if ($query->have_posts()) :
    while ($query->have_posts()): $query->the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <?php endwhile;
    else : 
    echo 'Query failed to find posts matching the criteria <br>';
    endif;
    wp_reset_postdata();

    Have a great weekend.

    Thread Starter ageingdj

    (@ageingdj)

    Hi there,
    I’ve replaced wp-admin & wp-includes with squeaky clean new folders but now everything’s gone blank, front and back ends.
    I changed config.php define('WP_DEBUG', false); to true and got:

    Fatal error: Call to undefined function wp_cache_get() in /home/k21ageingdj/public_html/wp-includes/functions.php on line 1364

    Fatal error: Call to undefined function wp_cache_close() in /home/k21ageingdj/public_html/wp-includes/load.php on line 681

    But there is nothing on line 1364

    Help!

    Thread Starter ageingdj

    (@ageingdj)

    Hi there,
    Sorry, I was too tired last night – I meant ‘cat’ not ‘cat_id’.
    As for the Manual Update, I’m struggling so I’ll finish it tomorrow.

    Thanks

    Thread Starter ageingdj

    (@ageingdj)

    Hi,Back again
    I’ve been playing with the Health Check plugin:
    I copied the code onto a new template file, copied this file into TwentySeventeen and a EDD theme called Themedd (it took someone weeks to think up that name) with the same results as before.
    'category_id' => 'bike rides', 'posts_per_page' => 15
    ie cat=> 112 returns “query failed to find”, cat=>’anything’ is ignored and the first 15 products are listed.
    The manual update looks a bit scary so I’ll wait until tomorrow
    Thanks
    PS As for the weekend, here in London there was a art festival called Lumiere which I managed to get involved in somehow (v cold, v wet, great fun but knackered!).

    Thread Starter ageingdj

    (@ageingdj)

    Hi there,
    I won’t get a chance to do this until Friday, possibly Monday (busy weekend!)

    Thanks

    Thread Starter ageingdj

    (@ageingdj)

    Hi there
    I spotted the 0=1 line and made no sense of it (it’s a long time since I’ve used SQL)
    The category id is 112 (I’ve tried different id’s with the same result).
    Now for health-check – I’m in troubleshooting mode and for some reason it wants to run TwentySeventeen but I’ve no idea how to run my php script as I can’t point a page at the template file the script is on (it’s the only way I know how – I was only on the first lesson of a beginers tutorial!).
    I’ve switched on the “use current theme” option and run the script (with no plugins) with the same results.

    Many thanks

    Thread Starter ageingdj

    (@ageingdj)

    Hi there,

    I haven’t used SQL for years!
    This is the query your code returned:

    $args = array( 'post_type' => array(
           'download'),
           'cat' => 112, 'posts_per_page' => 15,);
    $loop = new WP_Query( $args );
    echo "Query: {$loop->request}<br>\n";

    Query: SELECT SQL_CALC_FOUND_ROWS wpot_posts.ID FROM wpot_posts
    WHERE 1=1 AND ( 0 = 1 ) AND wpot_posts.post_type = ‘download’ AND (wpot_posts.post_status = ‘publish’ OR wpot_posts.post_status = ‘refunded’ OR wpot_posts.post_status = ‘failed’ OR wpot_posts.post_status = ‘revoked’ OR wpot_posts.post_status = ‘abandoned’ OR wpot_posts.post_status = ‘processing’ OR wpot_posts.post_status = ‘active’ OR wpot_posts.post_status = ‘inactive’ OR wpot_posts.post_status = ‘acf-disabled’ OR wpot_posts.post_status = ‘private’) GROUP BY wpot_posts.ID ORDER BY wpot_posts.post_date DESC LIMIT 0, 15

    Query failed to find posts matching the criteria

    Thanks

    Thread Starter ageingdj

    (@ageingdj)

    Hi there,
    ‘cat’ => 112, returns ‘Query failed to find posts matching the criteria’
    cat => ‘112’, returns ‘Query failed to find posts matching the criteria’
    ‘cat’ => ‘ ‘, returns random (I think) downloads
    ‘category’ => ‘AllyPally’ returns random downloads
    ‘category_name’ => ‘AllyPally’ returns ‘Query failed to find posts matching the criteria’ [AllyPally is the name of cat 112].
    It makes no sense!
    Many thanks
    Paul

    //Query Five starts here<br>
    <?php
    $args = array( 'post_type' => array(
           'download'),
           'category_name' => 'AllyPally', 'posts_per_page' => 15,);
    $loop = new WP_Query( $args );
    
    if ($loop->have_posts()) :
    while ($loop->have_posts()): $loop->the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <?php endwhile;
    else : 
    echo 'Query failed to find posts matching the criteria <br>';
    
    endif;
    wp_reset_postdata();
    ?>
Viewing 15 replies - 61 through 75 (of 92 total)