FlossieT
Forum Replies Created
-
Forum: Themes and Templates
In reply to: Problems creating index page of all postsOK – modifying that page template has got me all the elements I need, at least, so it’s now just a CSS challenge… Thanks.
Forum: Themes and Templates
In reply to: Problems creating index page of all postsThanks, I’ll try fiddling with the page template that creates. I would quite like to know how to code it properly though! Really struggling with searching for the solution.
@t31os_ I thought that was probably it…. I’ll try your approach – the various options I’d tried were dumping the jQuery portion in the page before any of the rest of it (i.e. even before the
<head>
declaration!)Thanks!
Sorry, further addition.
I’m now enqueueing jQuery in functions.php, using the following method:
function myfunc_jquery_init() { if (!is_admin()) { wp_enqueue_script('jquery'); } } add_action('init', 'myfunc_jquery_init');
and still get the same error message on the same line when I paste in the jQuery stuff. So I guess it’s not the explicit enqueueing that’s the problem (unless I’m doing that wrong too, of course).
Any other ideas? Or is it my enqueueing that’s the problem?
Unfortunately not (I’m not quite that much of a beginner!!) – I’d already modified the function names.
Edit to expand:
Is there something I’m not understanding about how to call jQuery in functions.php? After a bit of fiddling, I’m getting a slightly different error message, but it still seems to be related to the jQuery – it’s not happy with this line:
jQuery(document).ready(function() {
which is now throwing up the error:
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in (my-site-path)/functions.php on line 78
Do I need to have explicitly enqueued jQuery somewhere else before I can use it like this?
Forum: Fixing WordPress
In reply to: Problem with orderby in wp_list_bookmarks()Yes – that works fine. Is it a blooper in the codex documentation then?
Forum: Fixing WordPress
In reply to: Unable to retrieve custom field contents via get_post_metaFound the answer in this post in the forums: $post->ID wasn’t sufficient, get_the_ID() did the trick.
Forum: Fixing WordPress
In reply to: Listing recent posts in sidebar using a custom fieldThanks – I’ve gone through all of that documentation, and much of the stuff that’s linked to it, and yet I’m still getting nothing.
I’ll mark the original issue resolved and start a more specific thread!
Forum: Fixing WordPress
In reply to: Listing recent posts in sidebar using a custom fieldThanks. I’ve been knocking this around, and I can’t get it to display anything where the text should be.
The custom field is not empty, because the evaluation is successful.
Yet when I use get_post_meta to retrieve the field contents and try to echo it to the browser, it’s outputting nothing.
If I change ‘true’ to ‘false’ above, it echoes ‘Array’ – which suggests to me it isn’t finding any data. But I can’t see how that’s possible if it’s passed the evaluation.
Here’s my code in full:
<?php $args=array( 'meta_key'=>'custom-field-key', 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 10, 'caller_get_posts'=> 1 ); $customflag = null; $customflag = new WP_Query($args); if( $customflag->have_posts() ) { echo '<li id="recent-custom-posts" class="widget widget_recent_entries"><h2 class="widgettitle">Recent Posts</h2> <ul>' ; while ($customflag->have_posts()) : $customflag->the_post(); ?> <li><?php the_author(); ?>: <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"> <?php $customflagtext = get_post_meta($post->ID, "custom-field-key", false); if($customflagtext !== '') { echo $customflagtext; } ?> </a></li> <?php endwhile; echo '</ul></li>' ; } wp_reset_query(); // Restore global post data stomped by the_post(). ?>
This outputs a list of ten posts, each in the format ‘Author: Array’ (where Array is linked to the correct post).
If I put ‘false’ back to ‘true’ to retrieve (supposedly) a single string, I get nothing.
What am I missing? How can a field be not-empty and empty all at the same time?
Forum: Fixing WordPress
In reply to: Listing recent posts in sidebar using a custom fieldOK, now having trouble with a different bit of the same thing!
Instead of the link text being the post’s title, I want it to be the value of the same custom field we’re evaluating to generate the lists.
I’m looking at get_post_custom_values, but am obviously getting the syntax completely wrong – so where you have:
while ($my_query->have_posts()) : $my_query->the_post(); ?> <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p> <?php endwhile;
I have:
while ($my_query->have_posts()) : $my_query->the_post(); ?> <li><?php the_author(); ?><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> <?php get_post_custom_values('my-custom-field-key'); ?></a></p> <?php endwhile;
but nothing displays.
Sorry, I know this is really elementary…
Forum: Fixing WordPress
In reply to: Listing recent posts in sidebar using a custom fieldMANY thanks. Now I just need to pull it apart again so I can understand how/why it works…
It does take a long time to load – are there more efficient methods, or is it going to take extra time by its very nature (because of having to loop through the conditions)?