GenericBox
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: WP_Query Priority OrderingFigured it out!
It’s a little messy, and not as controllable as I would have liked – but its working, and the site for the client is a campaign landing page so will only be live for a few weeks/months anyway.
If anyone has a similar issue, of wanting to handle different WP_Query arguments from multiple Custom Post Types in the one loop, maybe this will help you out. IT IS VERY BESPOKE however, and I doubt much of it will make sense, but I tried to comment as much as I could.
I also ran into issues because I was using a plugin called WPML for translation into 3 different languages.
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // Get the page value $filter = get_query_var('filter'); // Get filter query var from permalink $langs = array('en','fr','nl'); // Define languages $notlangs = array_diff($langs, array(ICL_LANGUAGE_CODE)); // Create a new array from the languages minus the current language foreach($notlangs as $l) $lids[] = get_category_by_slug($l)->cat_ID; // Get the category IDs of the languages $pts = array('pt1','pt2','pt3','pt4'); // My Custom Post Types if(!in_array($filter, $pts)) $filter = array_diff($pts, array('pt1')); // Due to the conflicts with WPML, pt1 was causing the issues, so if the filter is all (as in, it isn't just "one" of the defined $pts, remove pt1 from the filter list // This is the main query - if $filter is just one post_type it runs as normal, if not, it is post_types minus pt1 $args = array('post_type' => $filter, 'posts_per_page' => 8, 'paged' => $paged, 'orderby' => 'menu_order', 'post_status' => 'publish', ); // This is the second query - this is for pt1 specifically, and has different args $eargs = array('post_type' => 'pt1', 'posts_per_page' => 8, 'paged' => $paged, 'category__not_in' => $lids, 'suppress_filters' => true ); $the_query = new WP_Query; // Create the main query if($filter=='pt1') $args=$eargs; // If the filter is for just pt1 by itself, make the pt1 specific args the main args $the_query->query($args); // Run the standard WP loop query if(is_array($filter)) { // If $filter is an array, meaning it is not JUST a single filter $ent_query = new WP_Query; // Create a new WP Query $ent_query->query($eargs); // Run the query with pt1 args, effectively running two simultaneous queries $the_query->posts = array_merge($the_query->posts, $ent_query->posts); // So then merge the two results into array, the original, "main" WP query $the_query->post_count = count($the_query->posts); // So that the page count isn't broken by the merge, recount the query shuffle($the_query->posts); // Randomise the results so it isn't 8 of each in a row }
Because the 3 less populated post_types are queried first, the top part of my gallery is now garuanteed to be populated by them first, and the shuffle after each merge ensures I get a nice random pattern until they disappear normally when there is no more left for that page.
I know this is highly specific – but hopefully some of the logic helps someone.
The important part is running two queries simultaneously and then merging both of those results into the original main query.
Thanks again Birgire, you got me thinking on the right track.
Regards,
GB.Forum: Fixing WordPress
In reply to: WP_Query Priority OrderingThanks for your response Birgire, the method makes sense. Thanks alot.
I will implement it now and let you know how it works, and if I have to tweak it in any way.
Regards,
GB.Forum: Plugins
In reply to: [Ultimate Posts Widget] Change Thumbnail ALT tagSorry – this code is wrong too. It shouldn’t be a count check – but you get my meaning.
Forum: Themes and Templates
In reply to: Images Not Showing On Iphone/mobile deviceYour images do not work at all on my or I assume anyone elses computers.
A quick inspect shows that all your images and links are pointing to:
https://localhost:8888/.../...
Unless I were to have your images on my localhost, and only if I were even running it on port 8888 – your images aren’t going to work.
My guess is that you need to set the new URL in the General Settings tab of the Administration console where it says “WordPress Address” and “Site Address”.
If you have hardcoded these images/links – then use relative paths or change them to your new domain.
Let me know how this goes.
GB.
Forum: Themes and Templates
In reply to: [Custom Community] having backgroud image repeat the whole widthIf you want to get rid of the smiley completely:
#header { background: none; }
For the Home page issue – I can’t really help you unless I see what code you are using to pull the Navigation menu from WordPress. You can’t View Source PHP.
Copy and paste your header.php file. Make sure to put it within
code tags
in the forum post.Forum: Themes and Templates
In reply to: [Custom Community] having backgroud image repeat the whole widthDid you fix the issue? I’m not sure of the problem on that link. Can you point it out?
Forum: Themes and Templates
In reply to: align text and titles?On your Gallery page, revisit your HTML.
Too many DIVs.
Forum: Themes and Templates
In reply to: align text and titles?Just add
float: left;
to the CSS of your images.
Forum: Fixing WordPress
In reply to: Add target applied to pagination links?I would just use a simple Slider jQuery to do it – it will look much cleaner and won’t require a page refresh.
jQuery Cycle is small and easy to use.
Just run a new WP_Query to pull the Latest News and put them within a <div> tag and attach Cycle to the div.
Forum: Themes and Templates
In reply to: tagline problem in mobile version of twentyeleven themeThe problem with min-width is that it will force the browser to scroll under that point, not that anything will go below 250px wide but still – I don’t think its the ideal solution.
Removing the margin is a simple solution that appears to work for me.
#site-description { margin: 0; }
Forum: Themes and Templates
In reply to: nav_link not showing at allBecause you have it inside the ELSE of the IF statement:
Following the current logic:
IF THERE ARE POSTS ... WHILE THERE ARE POSTS SHOW POST IF THERE ARE NO POSTS ... SHOW POSTS_NAV_LINK AND WRITE "Sorry, no posts matched your criteria."
As you can see, currently that code would only show the posts_nav_link if there were no posts.
You need to at it between the
endwhile;
and theelse:
<?php endwhile; posts_nav_link(); else: ?>
Forum: Fixing WordPress
In reply to: Disabling CommentsTo Disable comments on any future Pages or Posts you create, go to:
Settings > Discussion
In the first question — Default Article Settings — disable:
[ ] Allow people to post comments on new articles.
This will make comments disabled by default (unless overridden by individual posts)
Then, to disable them on any old articles, go down to the sixth option under “Other Comment Settings” and CHECK:
[ x ] Automatically close comments on articles older than [______] days
However *set the days to 0* (or 1).
Forum: Fixing WordPress
In reply to: Disabling CommentsIt is under Screen Options, of each individual Page or Post:
Pages > Page: [Screen Options] > Discussion
Then untick “Allow Comments”:
[ ] Allow Comments.
Forum: Themes and Templates
In reply to: [Custom Community] having backgroud image repeat the whole widthI depends how you define “repeat 100% of the width”.
If you mean repeat as it is defined by CSS – the one image tiled against each other, then create a child theme if you haven’t already, and in edit the style.css
If you want a Custom background to be repeated (ie – a background selected through the Administration console like TwentyTwelve) – then put this in your style.css:
body { background-repeat: repeat-x; }
If you are just hardcoding the background image, just include that above:
body { background: url('/relative/path/to/image.png') repeat-x; }
If you need something more specific, let us know the details.
Forum: Fixing WordPress
In reply to: PHP include in Plugin functionFound the issue, WordPress doesn’t like it when you link to the full address of a file from within a plugin, instead, using the relative path works.
However, I had to change my file names to more ..unique.. filenames as they were causing conflicts.
So, this works:
function jpvg_options_screen(){ include('jpvg_options.php'); }