Forum Replies Created
-
AuthorPosts
-
Stefaan5Member
Thanks!
Stefaan5MemberThanks Victor,
It's solved now.
It seems it was a cache issue. I think..Do you recommend a plugin for backups?
Stefaan5MemberSorry it took so long to give an update on this post, I was on a summer holiday!
But anyway, the issue was resolved by following the given tips.
The main issue seemed to be created when I generated a new WP_Query.
Modifying the loop in the archive-cpt file + single cpt file and using the pre_get_posts to alter the number of posts worked perfectly.Another issue resolved! Thanks Brad!
July 17, 2016 at 8:47 am in reply to: The best lightweight image-gallery plugin for Genesis? #189695Stefaan5MemberNeilgee, looks nice. Thx!
Stefaan5MemberThank you for this.
I'll get to work and see if this solves it!
Stefaan5MemberThanks for the quick reply.
I am using the custom fields so I can add individual custom posts through the wp-CMS.
And the plug-ins are super easy. But if ACF breaks if deactivated, I should probably code them. I'll have a look at the Executive Pro child theme for that.
Thanks for leading me in the right direction.I didn't know there was a genesis_get_custom_field function though! Any idea where I can find a list of all the built in functions for genesis?
Also, I am developing the site on a local server, using MAMP. So, I won't be able to show you the actual page.
But do you see anything that could result in the 404 page? As I said, the pagination does show up. It just always leads to a 404 page.July 12, 2016 at 9:11 am in reply to: The best lightweight image-gallery plugin for Genesis? #189289Stefaan5MemberHey, thanks.
I'll check it out!
Sorry for the extremely late reply. Didn't get a response message in my inbox for some kind of reason.Kind regards,
Stefaan
Stefaan5MemberFirst time doing that.
Here's the link:
Sorry for that later response. For some kind of reason I didn't get a response Email from Studiopress in my inbox.
Thanks for your quick reply though!
Stefaan5MemberBesides using the foreach loop, the following worked for a new Post type using the WP_query.
I was looking to create images with a url going to their respective pages.
Meaning I had had to create a post-type with the title, featured image and an advanced custom field for the custom url.//Create loop for custom post type 'book'
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action('genesis_loop', 'CPT_loop');function CPT_loop(){
$args = array(
'posts_per_page' => -1,
'post_type' => 'books',
'order' => 'ASC',
'order_by' => 'menu_order',
'paged' => $paged
);$loop = new WP_Query( $args );
if ( $loop->have_posts() ) :
echo '<ul id="book-grid">';
while ( $loop->have_posts() ) : $loop->the_post();
?> <li class="bookImg" style="background-image: url(<?php the_post_thumbnail_url(); ?>);">" class="overlay"> <h2><?php the_title() ?></h2>
<?php endwhile;
echo '';
do_action( 'genesis_after_endwhile' );
endif;wp_reset_postdata();
}Stefaan5MemberI think I made this more complex than I should have.
I was able to solve this issue through a different approach, using a simple foreach loop with a conditional.
This is the code://Add Sponsors through foreach-loop
add_action( 'genesis_after_entry', 'add_img_loop');function add_img_loop(){
echo '<ul id="sponsorimg-container">';
$sponsorimg1 = get_field('sponsor_1');
$sponsorimg2 = get_field('sponsor_2');
$sponsorimg3 = get_field('sponsor_3');
$sponsorimg4 = get_field('sponsor_4');
$sponsorimg5 = get_field('sponsor_5');
$sponsorimg6 = get_field('sponsor_6');
$sponsorimg7 = get_field('sponsor_7');
$sponsorimg8 = get_field('sponsor_8');
$sponsorimgarr = array( $sponsorimg1, $sponsorimg2, $sponsorimg3, $sponsorimg4, $sponsorimg5, $sponsorimg6, $sponsorimg7, $sponsorimg8);foreach ( $sponsorimgarr as $sponsorimage){
if( !empty ($sponsorimage) ){
echo '<li class="SponsorImg">';
}
}
echo '';
}Stefaan5MemberThat's right, I've created a CPT through CPT UI-plugin and a field through ACF-plugin.
These do not have to be placed in a widget.1. The CPT 'sponsor-images' has a field 'sponsor-image'. Which has a value of one image.
I want to be able to add sponsor images and remove them through the WP-CMS in the CPT 'sponsor-images'. The images do not need a link.2. The CPT has 8 sponsor images for the moment. But I want to be able to remove and add to this through the CMS.
The field contains only 1 image per sponsor.3.This only has to be displayed on the front-page.php, preferably in the location genesis_after_entry.
The amount of images that should be displayed are the amount of sponsors created in the CMS.I've gotten it to half-work with a forreach loop with the following code I got from the WP-forums.
However, when I add more sponsors, the new images aren't displayed anymore.
=============================================================================================
add_action( 'genesis_after_entry', 'image_looper' );function image_looper(){
$post_type = 'sponsor-images';
global $wpdb;
$where = get_posts_by_author_sql( $post_type );
$query = "SELECT * FROM $wpdb->posts p where p.post_type = 'attachment' AND (p.post_mime_type LIKE 'image/%') AND (p.post_status = 'inherit') AND p.post_parent IN (SELECT $wpdb->posts.ID FROM $wpdb->posts ) ORDER BY p.post_date DESC";
$results = $wpdb->get_results( $query );if ( $results ) {
foreach ( (array) $results as $image ) {
$url = get_attachment_link($image->post_parent);
$thumb = wp_get_attachment_thumb_url( $image->ID );
$alt = get_post_meta($image->ID, '_wp_attachment_image_alt', true);
echo '<li class="SponsorImg">';
}
}
}
=============================================================================================Stefaan5MemberThanks for the help Victor.
I've been trying to figure this out for days but I'm not sure what to do next though.
I can't get the values to loop.
I'm trying to output the images from the field 'sponsor-image' from the custom post type 'sponsor-images'. This in the genesis_entry_footer location.Do I use the WP_query on the front-page? Which arguments should I use then?
Regards,
Stefaan
-
AuthorPosts