richgcook
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Using wp_insert_user on a CPT post submission – odd resultsAfter many days, I managed to solve this.
Because I am using ACF, I should use the built-in action to do what you want after the data is saved.
Because this action will be called every time a post is created/saved, etc, I will probably need to add an if statement to check if it’s the post type you’re looking for.
All of the fields should be available via
$_POST['fields']
as well if get_post_meta does not return what I’m looking for.The modified code below uses the ACF action AFTER the post has been saved, so the meta should be available. I can do a var_dump on the
$_POST['fields']
to see what POST data is available as well.https://www.advancedcustomfields.com/resources/actions/acfsave_post/
add_action('acf/save_post', 'people_postdata', 20); function people_postdata($post_id) { global $wpdb; $firstname = get_post_meta($post_id, 'first_name', true); $lastname = get_post_meta($post_id, 'last_name', true); $email = get_post_meta($post_id, 'email_address', true); $password = get_post_meta($post_id, 'password', true); $username = preg_replace('/[^A-Za-z0-9]/', '', strtolower(get_the_title($post_id))); $userargs = array( 'first_name' => $firstname, 'last_name' => $lastname, 'user_login' => $username, 'user_email' => $email, 'user_pass' => $password, 'role' => 'basic' ); // var_dump($userargs); wp_insert_user($userargs); }
Forum: Themes and Templates
In reply to: Setting attachment size dynamicallyChoosing a size from the ‘Add media’ screen doesn’t seem to do anything.
[ Please do not bump, that’s not permitted here. ]
Forum: Themes and Templates
In reply to: Navigation/Sub Navigation and how it displaysI can’t seem to edit the post, but my navigation is actually set up like this:
<div class="grid_3"> <ul class="sub-navigation"> <?php $parent_page = get_page_by_title( 'Home' ); wp_list_pages( 'title_li=&depth=1&child_of=' . $parent_page->ID ); ?> </ul> </div> <div class="grid_5"> <?php $children = wp_list_pages('title_li=&sort_column=menu_order&child_of='.$post->ID.'&echo=0'); if ($children) { ?> <ul class="sub-sub-navigation"> <?php echo $children; ?> </ul> <?php } ?> </div>
Forum: Themes and Templates
In reply to: Same posts being displayed on next page (pagination)Hi @esmi… I’m at work now so can’t do this straight away, but I never tried just removing the whole top loop to see if it was causing problems and the same issues occured.
Forum: Themes and Templates
In reply to: Same posts being displayed on next page (pagination)Hi @esmi, thanks for your help. I changed both queries to the structure you suggested, but it’s still causing the same problem. The top query doesn’t need pagination… it’s only pulling in one post, which is the latest post, that’s why the rest are offset. Any ideas? Many thanks for your help.
Forum: Themes and Templates
In reply to: Same posts being displayed on next page (pagination)Hi @esmi – same issue occurs.
You can see the page I’m working on here:
https://richgc.com/dust/c8/events/
There’s two loops on this page, so maybe that’s why?
Full code for page:
<div class="container_12 events-landing-first-post-container"> <?php query_posts("posts_per_page=1&cat=8"); while ( have_posts() ) : the_post(); ?> <div class="prefix_6 grid_6"> <div class="events-landing-first-post"> <h3><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" ><?php the_title(); ?></a></h3> <?php //starkers_posted_on(); ?> <?php the_excerpt(); ?> <footer> <div class="social-sharing"> <a class="ss-facebook" href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>">Share on Facebook</a> <a class="ss-twitter" href="https://twitter.com/share?&text=<?php the_title(); ?> via%20@Corridor8&url=<?php the_permalink(); ?>">Share on Twitter</a> </div> </footer> </div> </div> <?php endwhile; ?><?php wp_reset_query();?> </div> <div class="container_12"> <div class="events-landing-rest-container"> <?php $args = array( 'cat' => '8', 'post_type' => 'post', 'posts_per_page' => 6, 'offset' => 1, 'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1), ); query_posts($args); while (have_posts()) : the_post(); ?> <div class="prefix_1 grid_5 events-landing-rest"> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php if ( has_post_thumbnail() ) { ?> <a class="post-featured-image" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" > <?php the_post_thumbnail(); ?> </a> <?php } ?> <header> <h2><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'starkers' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2> <?php starkers_posted_on(); ?> </header> <?php the_excerpt(); ?> <footer> <p><?php if ( count( get_the_category() ) ) : ?> <?php printf( __( '%2$s', 'starkers' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?> | <?php endif; ?> <?php comments_popup_link( __( 'Leave a comment', 'starkers' ), __( '1 Comment', 'starkers' ), __( '% Comments', 'starkers' ) ); ?></p> <div class="social-sharing"> <a class="ss-facebook" href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>">Share on Facebook</a> <a class="ss-twitter" href="https://twitter.com/share?&text=<?php the_title(); ?> via%20@Corridor8&url=<?php the_permalink(); ?>">Share on Twitter</a> </div> </footer> </article> </div> <?php endwhile; // End the loop. Whew. ?> </div></div> <?php /* Display navigation to next/previous pages when applicable */ ?> <div class="container_12"> <div class="prefix_1 grid_11"> <nav class="prev-next-container"> <span class="newer-posts"><?php previous_posts_link( __( '← Newer events', 'starkers' ) ); ?></span> <span class="older-posts"><?php next_posts_link( __( 'Older events → ', 'starkers' ) ); ?></span> </nav> </div> </div> <?php wp_reset_query();?>
Forum: Fixing WordPress
In reply to: WordPress – List child pages but link them as an anchorSure thing:
This is for the navigation list on the page:
<?php if( is_page(155) ){ $args = array( 'child_of' => 155, 'sort_column' => menu_order, 'parent' => 155, 'hierarchical' => 0 ); $mypages = get_pages($args); ?> <ul> <?php foreach( $mypages as $page ) { ?> <li><a href="#<?php echo $page->post_name; ?>" class="smooth-scroll"><?php echo $page->post_title; ?></a></li> <?php } ?> </ul> <?php } ?>
And this is how I dumped out the images and added the anchor to them. You can see the ID for each title is the slug, and in the navigation at the top, each link echos the post/page name but with a # in front.
<?php $postslist = get_pages('number=9999&sort_order=ASC&sort_column=menu_order&child_of=155'); foreach ($postslist as $post) : setup_postdata($post); ?> <ul class="main-projects-list"> <?php $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID, 'orderby' => 'menu_order', 'order' => 'ASC', ); $attachments = get_posts( $args ); $post_title = get_the_title($post->ID); // We get the post title if ( $attachments ) { foreach ( $attachments as $attachment ) { $main_page_title = apply_filters( 'the_title', $post_title ); $img_title = apply_filters( 'the_title', $attachment->post_title ); $slug = basename(get_permalink()); echo '<li class="each-image">'; echo '<div class="each-exhibition-text">'; echo '<h1 id="'; echo $slug; echo '">'; echo $main_page_title; echo '</h1>'; echo the_content(); echo '</div>'; echo wp_get_attachment_image( $attachment->ID, 'large' , false, array('title' => $img_title)); echo '<p>'; echo $img_title; echo '</p>'; } } ?> <?php endforeach; ?>
Hope this helps,
RForum: Fixing WordPress
In reply to: WordPress attachments in query_posts…It’s the grid view I’m looking at (https://itsfoolsgold.com/grid/) the default and grid views both use different templates.
Forum: Fixing WordPress
In reply to: WordPress attachments in query_posts…Thanks for your help with this, keesiemeijer.
Still the same problem – you can see it on that site again.
Forum: Fixing WordPress
In reply to: WordPress attachments in query_posts…I seem to have got something working with this below, but it’s pulling in one post, infinitely (see here: https://goo.gl/4IlWG)
<?php $ID = get_the_ID(); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("order=DESC&orderby=post_date&posts_per_page=8&paged=$paged"); while ( have_posts() ) : the_post(); ?> <?php $args = array( 'post_type' => 'attachment', 'post_status' => null, 'post_parent' => null, ); $attachments = get_posts( $args ); if ($attachments) { foreach ( $attachments as $post ) { setup_postdata($post); the_attachment_link($post->ID, true); the_excerpt(); } } ?> <?php endwhile; ?>
Forum: Fixing WordPress
In reply to: Twitter feed and Javascript/CSSHi!
I’m using the Twitter feed you handed me but it’s not updating the tweets… very weird. Any ideas?
R
Forum: Fixing WordPress
In reply to: Twitter feed and Javascript/CSSHi again,
This actually worked out great and thanks so much for bringing it to my attention… much better than javascript!
Cheers,
RForum: Fixing WordPress
In reply to: Twitter feed and Javascript/CSSSorry, website is https://richardgordoncook.com/curatorial-noise-club
I’ll definitely check out that link when I get back from work. Thanks so far.