md84
Forum Replies Created
-
This is what I needed! Great plugin ??
$args = array( post_type => attachment, numberposts => -1, category => $cat_ID ); $attachments = get_posts($args); if($attachments){ foreach($attachments as $attachment){ $image_attributes = wp_get_attachment_image_src($attachment->ID, 'full'); echo '<img src="'.$image_attributes[0].'">'; } }
Forum: Plugins
In reply to: [Yoast SEO] Page SEO section not savingSame problem here. For posts it works though, not for pages.
Forum: Fixing WordPress
In reply to: post_parent problemTried it, didn’t work! The problem remained.
It’s still the same as explained above. All attachments are shown when using ‘null’ as value for argument ‘post_parent’, but when using ‘$post->ID’ or argument ‘include’ with as value a number of a specified post, it doesn’t work and shows nothing.
Forum: Fixing WordPress
In reply to: post_parent problemHey, thanks for the reply. Let me rephrase it.
In my code, when I use ‘null’ as value for argument ‘post_parent’, it shows all attachments (as thumbnails), so that works. But what I actually want is only showing attachments from certain posts. The value ‘$post->ID’ should provide me with the attachments of its parent, but it doesn’t work (no attachments show).
I also tried using global $wp_query, $post; but it didn’t solve it.
Forum: Fixing WordPress
In reply to: How to alter attachment URLs (of images) inside a certain post?Cannot get it to work, bleh!
Below my complete code. Question above remains the same.<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $wp_query = new WP_Query(); $wp_query -> query('category_name=photo&posts_per_page=1&order=ASC&paged=' . $paged); ?> <?php while($wp_query -> have_posts()) : $wp_query -> the_post(); ?> <?php if(is_paged()){ ?> <?php $args = array( 'post_type' => 'attachment', 'numberposts' => 25, 'post_parent' => $post->ID, 'order' => 'ASC' ); $attachments = get_posts($args); if($attachments){ foreach($attachments as $attachment){ $atturl = wp_get_attachment_thumb_url($attachment->ID); $attlink = get_attachment_link($attachment->ID) . '&paged=' . $paged; echo '<a href="' . $attlink . '"><img src="' . $atturl . '"></a>'; } }; ?> <?php } else { ?> <?php the_content(); ?> <?php }; ?> <?php endwhile; ?>
Forum: Fixing WordPress
In reply to: How to alter attachment URLs (of images) inside a certain post?I solved it! Instead of using the wp_get_attachment_link() function I used two new variables ($atturl and $attlink) which I combined later on with some simple HTML.
Problem now is that the post_parent argument doesn’t work correctly. When ‘null’ it does show my attachments (multiple thumbnails), but when I use $post->ID (or the ‘include’ argument with as value the numeric post ID), it shows blank. What is the problem?
Can anybody help?
<?php $args = array( 'post_type' => 'attachment', 'numberposts' => 25, 'post_parent' => $post->ID, 'order' => 'ASC' ); $attachments = get_posts($args); if($attachments){ foreach($attachments as $attachment){ $atturl = wp_get_attachment_thumb_url($attachment->ID); $attlink = get_attachment_link($attachment->ID) . '&paged=' . $paged; echo '<a href="' . $attlink . '"><img src="' . $atturl . '"></a>'; } }; ?>
Forum: Fixing WordPress
In reply to: How to alter attachment URLs (of images) inside a certain post?I now have this, but it doesn’t work. Can somebody help me?
<?php if(is_paged()){ ?> <?php $args = array('order'=>'ASC', 'post_type'=>'attachment', 'post_parent'=>$post->ID, 'post_mime_type'=>'image', 'post_status'=>null, 'numberposts'=>-1,); $attachments = get_posts($args); if($attachments){ foreach($attachments as $attachment){ echo wp_get_attachment_link($attachment->ID . '&paged=' . $paged, 'thumbnail', true, false); } }; the_content(); ?> <?php } else { ?> <?php the_content(); ?> <?php }; ?>
Forum: Fixing WordPress
In reply to: Pagination questionSolved!
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $wp_query = new WP_Query(); $wp_query -> query('category_name=film&posts_per_page=15&paged=' . $paged); ?> <ul style="list-style:none;"> <?php while($wp_query -> have_posts()) : $wp_query -> the_post(); ?> <li> <?php if(is_paged()){ ?> <a href="<?php echo 'https://xxx/your_theme_name/?p=' . $post -> ID . '&paged=' . $paged; ?>"><?php the_title(); ?></a> <?php } else { ?> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <?php }; ?> </li> <?php endwhile; ?> <p><?php posts_nav_link(); ?></p> </ul>
Forum: Fixing WordPress
In reply to: Pagination questionI now have this, but it still does not work. The code under else is incorrect. Can somebody help me?
<?php if(!is_paged($paged)){ $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("category_name=film&posts_per_page=15&paged=$paged"); } else { query_posts("category_name=film&posts_per_page=15&paged=$paged"); } ?> <ul style="list-style:none;"> <?php while(have_posts()) : the_post(); ?> <li> <a href="<?php the_permalink() ?>"><?php the_title(); ?></a> </li> <?php endwhile; ?> <p><?php wp_pagenavi(); ?></p> </ul>
Forum: Themes and Templates
In reply to: How to show previous/next links when listing post titles?This worked for me!
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("category_name=film&posts_per_page=15&paged=$paged"); ?> <ul style="list-style:none;"> <?php while(have_posts()) : the_post(); ?> <li> <a href="<?php the_permalink() ?>"><?php the_title(); ?></a> </li> <?php endwhile; ?> <p><?php wp_pagenavi(); ?></p> </ul>
I used a plugin to alter the appearance of my page nav. You can also use:
<?php posts_nav_link(); ?> instead of <?php wp_pagenavi(); ?>
Forum: Themes and Templates
In reply to: Opening posts in one ‘postholder’ on a pageI found the solution in the ‘Single Post Template’ plugin, which let you use a template file for posts.
Forum: Themes and Templates
In reply to: Opening posts in one ‘postholder’ on a pageAdditional information:
– The above mentioned website is the static version, I am working on the WordPress version from a local server (XAMPP).Forum: Fixing WordPress
In reply to: WP’s built-in gallery opens images, when clicked, on a blank pageI found the solution!
– As a plugin I used ‘Lightbox-2’ (it also worked with ‘Lightbox Plus’).
– When adding an image make sure that the image’s hyperlink is linked to the file itself instead of the post.
– Make sure that <?php wp_head(); ?> is added to your header.php file (for the specific location look at the default theme).
– Make sure that <?php wp_footer(); ?> is added to your footer.php file (for the specific location look at the default theme).
– Sometimes it is necessary to select certain options within the plugin itself.This worked for me, yes!
Forum: Fixing WordPress
In reply to: WP’s built-in gallery opens images, when clicked, on a blank pageI am still having problems with this, can somebody help me please…
Forum: Fixing WordPress
In reply to: WP’s built-in gallery opens images, when clicked, on a blank pageCan somebody please help me?
(Also duplicating the page.php and turning it into the single.php does not the trick for me. So I’m still stuck.)