pk-71
Forum Replies Created
-
Thanks Arnaud. I was looking very late at night and I think my brain was basically running on empty.
Forum: Fixing WordPress
In reply to: Version of jQuery In WordPress Failing Security AuditThanks Steven.
@bcworkz. As with every question you’ve ever answered for me on here I just don’t understand any of that. If you’re not going to offer proper examples or code it might be better to just not answer questions going forward?
Hi @tugbucket I meant to say as well if you cut and paste this answer in the stackoverflow question (link below) we’ll happily assign you as the correct answer again. I forgot to mention that. Thanks again
Thanks that worked. I only need the previous posts and tweaked it so I could incorporate it into an anchor link as per below. I can’t thank you enough, coming from someone who still has plenty to learn it’s been a godsend.
<?php $all_ids = get_posts(array( 'fields' => 'ids', 'posts_per_page' => -1, 'post_type' => $cpt, 'order_by' => 'post_date', 'order' => 'ASC', )); $prev_key = array_search($current_id, $all_ids) - 2; $next_key = array_search($current_id, $all_ids) + 2; if(array_key_exists($prev_key, $all_ids)){ $prev_link = get_the_permalink($all_ids[$prev_key]); ?> <a href="<?php echo $prev_link; ?>">Next Post</a> <?php } ?>
@tugbucket thanks. You should’ve got the bounty too.
One other thing, do you know how to solve the issue in the link below? It’s a side effect of having two posts on the
single-cpt.php
page.Hi @tugbucket Thanks for this answer it worked !
I realised when I used your answer I actually wanted the selected post as the first of the two and then the previous post so I changed the next posts etc to
get_previous_post();
and did the order as'DESC'
Are you on StackOverflow because my other half also posted this question on there and she put a 100 point bounty on it so if you are you can just cut and paste your answer in and we’ll give you the 100 bounty points.
Thanks again for taking the time to help !
Hi @bcworkz would you be able to give some pointers / code to look at for me to get started on? The WP_Query code is a snippet I’ve always used, but I’m still only really at basic to intermediate level so am at a bit of a loss where to start with the above advice. Thanks for taking the time to answer.
Forum: Developing with WordPress
In reply to: Pagination Not Working on `WP_Query` Archive PageHow do I know what is the main query and what isn’t? This is all new to me and when I read articles it’s so confusing. I have the above
WP_Query()
(in the original question) and thepaginate_links()
function and the rest of the page is HTML. TheWP_Query()
is pulled into an archive page with the URLexample.com/articles
(there is a custom post type of articles) and as you can see on the original post this archive page actually pulls in two custom post types with because of the'post_type'=> array('articles', 'featured')
line in theWP_Query()
But I have no idea how main and secondary queries work or how to approach this? The documentation on this seems very scant.
Forum: Developing with WordPress
In reply to: Pagination Not Working on `WP_Query` Archive PageI’ve looked at that already and can’t seem to work out how to use it with a WP_Query() that is using
offset
. The reason it isn’t working seems to be two-fold: WP_query() affects pagination out of the box, as does usingoffset
. I’m at a bit of a loss where to start because PHP is all new to me.OK thanks I’ll have a play around. I’m don’t do that much development with WordPress so it is all a bit new.
Hi – Would that go in my
functions.php
file orheader.php
file?Forum: Developing with WordPress
In reply to: Pulling In A Specific Image with wp_get_attachment_image()I’ve found the problem. I’m missing the
echo
. A thousand apologies.Forum: Developing with WordPress
In reply to: Pulling In A Specific Image with wp_get_attachment_image()Hi Steve,
I changed it to
src="<?php wp_get_attachment_image( 142, 'large', false, '' );?>"
but it still isn’t working. When I say not working I mean the image doesn’t show in the frontend. All I’m getting is the alt text (the alt text is added in the template file and doesn’t come from the media library).Paul
Forum: Fixing WordPress
In reply to: is_tax() conditional tag not workingActually Joy, don’t worry I’ve found the source of the other problem. I need to change
is_archive('sites')
tois_post_type_archive('sites')
Thanks for you help !