wpismypuppet
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Pagination on a generated page not blog postI apologize if I explained too much. I assumed from your question that you might not have know since you asked what the line did. I didn’t mean to insult if indeed I did.
As far as get_posts()… if you look at the reference, you can pass “paged” because get_posts() uses WP_Query(). I find it better than WP_Query because it won’t alter the main loop. There is a line on the reference page that says:
For full parameters list see WP_Query.
On that page, it indicates the use of the “paged” parameter. Please try the code… I have used the exact same code on 5 different websites we’ve used and it works. The only part that may not work is where I implemented your code, because I haven’t tested that piece, but I’m sure it works.
Forum: Fixing WordPress
In reply to: Pagination on a generated page not blog postYou are correct… you cannot pass paged as a parameter for get_pages(). But you’ll note that I use get_posts(), not get_pages(). Don’t be confused by the word “post” as EVERYTHING in WordPress is actually a “post”. These “posts” have labels such as attachment, post, page, and then custom post types. So using get_posts() and looking for “post_type” of “page”, you’ll only return pages, and exclude everything else.
And the line
$args['posts_per_page'] = $posts_per_page;simply adds the parameter of “posts_per_page” to the arguments so when get_posts() is called the second time, you return only x number of posts (where x = $posts_per_page variable which is assigned as the first line of code in the block I sent you). By using a variable (which you can see is used more than once throughout the block of code), you can just change the variable from 6 to however many posts (or pages in your case) you want to show per page without having to scan all the code for the number 6 and having to change it a few different times. It reduces user error if you miss one 🙂We don’t want to add “posts_per_page” the FIRST time we call get_posts() because we need to get ALL results, not just 6 at a time. This is critical for making the pagination work as the pagination needs to know the total number of posts so it can paginate properly.
Forum: Fixing WordPress
In reply to: Pagination on a generated page not blog postYou won’t be able to paginate using a $wpdb query. Your query looks simple enough, however, to just use get_posts(). Here is how I would do it:
<?php $posts_per_page = 6; // how many posts you want per page $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_type' => 'page', 'post_status' => 'publish', 'paged' => $paged ); $postslist = get_posts( $args ); $max_num_pages = ceil( sizeof( $postlist ) / $posts_per_page ); $args['posts_per_page'] = $posts_per_page; $postslist = get_posts( $args ); if( ! empty( $postlists ) ) : echo '<div id="primary" class="content-area">'; echo '<div id="content" class="site-content" role="main">'; foreach( $postslist as $post) : setup_postdata($post); the_content(); $category = get_the_category(); if( isset( $category ) && ! empty( $category ) ) : if( $category[0]->cat_name == "Blog" ) : echo '<article id="post-' . get_the_ID() . '" '; post_class(); echo '></article>'; endif; endif; endforeach; $big = 999999999; $pagelinks = paginate_links( array( 'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var('paged') ), 'total' => $max_num_pages )); if( ! empty( $pagelinks ) ) : echo '<div class="postnav clear">' . $pagelinks . '</div>'; endif; echo '</div></div>'; else : header( 'Location: ' . esc_url( home_url( '/' ) ) . '/404' ); endif; ?>Note that we need to do get_posts() twice. The first time get ALL the pages you are looking for, so we can obtain a total number of posts since $wp_query->max_num_pages usually doesn’t work for me (even when you call it globally). Then we call it again to get the first 6 posts (or pages).
This code isn’t fully tested, but I’ve used very similar code on many of our websites, so I know it “should” work. The only thing I can’t guarantee is your code where you try to get the category. However it looks right to me. Let me know how it pans out.
Forum: Fixing WordPress
In reply to: the_post() after new wp_query()Try using get_posts() to retrieve related posts… it doesn’t alter the main Loop…
Forum: Fixing WordPress
In reply to: Email form and PHP shortcodeWordPress editor has a way of doing strange things to code. Typically in a situation like this I would either use a form plugin, or simply create a page template where I could put my PHP code and not have to worry about corruption. The only reason I suggested what I did is because of your PHP plugin you are using. Let me know how it goes.
Forum: Fixing WordPress
In reply to: Email form and PHP shortcodeIf the PHP code is on the same page as the form, then simply use:
<form action="" method="post" enctype="text/plain">add a submit button to the form, or at least a hidden field set to 1:
<input type="submit" name="action" value="Send Email" />Then wrap all your PHP around an if statement to check if you submit button, or hidden variable set to 1, exists:
<?php if( isset( $_POST['action'] ) ) { $from="doNotReply@widdle.com"; $check1=$_POST['check1']; $check2=$_POST['check2']; $check3=$_POST['check3']; mail("talon77email@talon77.com", "Form Submission Notice", $check1 , "From: $from"); print "Your form has been submitted"; } ?>If your code is not on the same page as the form, you’ll need to submit the form and get directed to the page that does contain that code. What is the reason for the shortcode, out of curiosity?
Forum: Fixing WordPress
In reply to: Gallery FilterHow good are you at programming? A jQuery filter would look really cool… something like this one:
This way if JS isn’t supported people will still see all 200 photos. If JS is supported, they get cool animations.
Forum: Fixing WordPress
In reply to: DNSAh… the printed materials piece shouldn’t be that big a deal. If someone types in .net and is forwarded to .com, they most likely wouldn’t even notice. The average web user isn’t that observant.
What you are essentially looking to do is mirror the domains. Some web hosting companies, such as Dreamhost, offer this as a service, so check with your hosting company. However, to avoid SEO problems you’d have to add a lot of code to your site such as
rel="canonical"tags to tell search engines what’s real and what’s a “copy”. As I mentioned, more work than it’s worth.Companies often change domain names and what not if the company name itself has to change… We’ve done it a number of times for different clients. Using 301 redirects to point a user to the new domain name is really the best option… and most of those companies have tons of printed material with their old domain name on it!
Best of luck!
Forum: Fixing WordPress
In reply to: DNSIts more work than it’s worth… plus you’ll kill your SEO ranking by duplicating content. It’s better to forward the domains… ie, .net is forwarded to .com. Is there a reason you’d like the .net to remain?
Forum: Fixing WordPress
In reply to: Responsive ImagesRead this in detail…
http://css-tricks.com/perfect-full-page-background-image/
While Tokant is correct, this method won’t work in older browsers. If you don’t care about older browsers, then it’s not a problem. If you want to be as cross-browser as possible, the link I provided shows how to make that happen.
Also think about “responsible” design. Meaning that you don’t want to dish a 1024×768 pixel image to a mobile device. The bottom part of the link talks about using jQuery to dish out the properly sized photos…
Forum: Fixing WordPress
In reply to: blank wp-adminNo problem… glad I could help!
Forum: Fixing WordPress
In reply to: Trying to center these images.Just noted that you wanted the three images side by side…
In that case:
#box p { float: left; }But again, you need to fix your code. The images are all messed up code wise and that’s going to cause all kinds of problems.
Forum: Fixing WordPress
In reply to: blank wp-adminCheck your PHP error log… it’ll give you a detailed reason which you can then post here if you need more help.
A blank white screen means a PHP error, but your configuration is set to suppress errors.
Forum: Fixing WordPress
In reply to: Trying to center these images.It’s because your div with class “box” is floating left, so it’s width is reduced to the largest element inside, which is the image. Either center that div, or if I were you I’d remove the float: left; and add text-align: center;
You should also note that the code used to put those images on the page is corrupt. You have anchors around the images, but they aren’t closed right and the image is being created within the anchor tag. It “looks” ok on most browser because they are forgiving, but you’ll have issues with some if you don’t correct the problem.
Forum: Fixing WordPress
In reply to: Custom Mega MenuWell yes, it is final in that it is what the function will output, but you can add code to your custom walker to add more code. In your case, I’m assuming you want to have columns of ULs floating left, correct?
What I would do, if I were you… I would add a class of “break” or “col-break” or something equivalent on your “level two” elements where you want the column to break. You can add this class where you create the menu itself, in the admin area. If you don’t see a field for “class”, then open the screen options and check off the “class” box. Then I would write my custom walker to check each element for that class and, if found, pump out a:
</div><div class="col">So where you have code to create your:
<div class="drop-down">Add in the starting div so it looks like this:
<div class="drop-down"><div class="col">Then whenever you find your class, “col-break” on the li, pump out the:
</div><div class="col">and where you have code to close your “drop-down” div, close the “col”:
</div></div>Make sense? Then use CSS to float the columns (“col”).