backbone
Forum Replies Created
-
Forum: Plugins
In reply to: [Co-Authors Plus] Query all posts of author even if he/she is co-author@sikorat
Co Authors Plus taxonomy ‘author’ is attached to the post_type ‘guest-author’. The tax_query looks up ‘term_relationship’ table for posts by assigned coauthor_id (post_id) from the ‘term_taxonomy_id’ matched by taxonomy = ‘author’ and term_id = ‘$person->ID’. I’m not sure the $person->ID you obtain is a guest-author or a user./** * WP_Query args setting * @link https://developer.wordpress.org/reference/classes/wp_query/ */ $args = array( /* to search all post types, set to 'any' * or omit, defaults to 'any' when tax_query is set * or limit multiple values with array( 'video', 'post' ) */ 'post_type' => 'video', 'post_status' => 'publish', //omit, default is 'publish' 'posts_per_page' => 3, 'tax_query' => array( array( 'taxonomy' => 'author', 'field' => 'term_id', 'terms' => $person->ID, ) ) );Example in use:
/** * WP PHP coding standards * @link https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/ */ /** * Check if on an existing author archive page * Guest author is not a user, therefore the typical 'author_id' is not a user_id. * Guest author is stored as a post, guest_id = post_id * * @link https://developer.wordpress.org/reference/functions/is_author/ * @link https://developer.wordpress.org/reference/functions/get_queried_object/ */ if ( is_author() ) : $guests = array( get_queried_object() ); elseif ( is_single() ) : $guests = get_coauthors(); else : return; //no point continuing endif; foreach ( $guests as $guest ) : $args = array( 'post_type' => 'video', //or array( 'video', 'post' ) 'posts_per_page' => 3, 'tax_query' => array( array( 'taxonomy' => 'author', 'field' => 'term_id', 'terms' => $guest->ID, ) ) ); $kq = new WP_Query( $args ); if ( $kq->have_posts() ) : ?> <ul data-author="<?php echo $guest->ID; ?>" class="resources__list"> <?php while ( $kq->have_posts() ) : $kq->the_post(); get_template_part( 'template-parts/content', 'article' ); endwhile; wp_reset_postdata(); ?> </ul> <?php else : echo "<!-- 'no posts matched query' -->"; endif; endforeach;Forum: Plugins
In reply to: [Co-Authors Plus] Delete A Co-Author in MySQL@gregcrowe Why not create a new admin user and delete the one in question?
@jeffsydor-bipc
Find all guest authors in posts table. *Supply your posts table name.*
Select * FROM*posts*WHEREpost_typeLIKEguest-authorChanging the username, 4 tables to be updated.
author = ID //is the post_id in the posts table
slug = display-name-lower-casewp_posts
post_id| post_name
author | cap-slugwp_post_meta
post_id| meta_key | meta_value
author | cap-user_login | slugwp_terms (update both name and slug values)
term_id| name | slug
author | slug | cap-slugwp_term_taxonomy
term_id| description
author | %slug% (word match in string)Once done with edits. Clear permalink cache.
Go to Admin > Settings > Permalink and just click ‘Save Changes’.I can’t edit or delete the previous reply. I made an error in the query args on the the author key. That is for standard user.
if ( is_author() ) $post_id = get_queried_object_id(); $coauthors = get_coauthors( $post_id ); if ( ! $coauthors ) return; foreach( $coauthors as $coauthor ) { $posts = new WP_Query( array( 'orderby' => 'date', 'order' => 'DESC', 'tax_query' => array( array( 'taxonomy' => 'author', 'field' => 'name', 'terms' => $coauthor->user_nicename, ) ) ) ); if ( ! $posts->have_posts() ) continue; while ( $posts->have_posts() ) : $posts->the_post(); ?> <div class="entry-summary"> <figure class="post-thumbnail"> <a href="<?php the_permalink(); ?>"> <?php the_post_thumbnail( 'article_archive' ); ?> </a> </figure> </div> <?php endwhile; wp_reset_postdata(); }Forum: Plugins
In reply to: [Co-Authors Plus] How to use function coauthors_get_avatar ?$coauthors = get_coauthors(); if ( ! $coauthors ) { return; } foreach( $coauthors as $coauthor ) { $avatar = coauthors_get_avatar( $coauthor, 150, '', $coauthor->display_name, '' ); echo <<<EOT <div class="author-metabox" id="{$coauthor->ID}"> <figure class="avatar">{$avatar}</figure> <div class="author-meta"> <h4>{$coauthor->display_name}</h4> <p>{$coauthor->description}</p> </div> </div> EOT; }$posts = new WP_Query( array( 'author' => get_queried_object_id(), 'orderby' => 'date', 'order' => 'DESC', ) ); if ( $posts->have_posts() ) : while ( $posts->have_posts() ) : $posts->the_post(); ?> <div class="entry-summary"> <figure class="post-thumbnail"> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'article_arhive' ); ?></a> </figure> </div> <?php endwhile; wp_reset_postdata(); endif;I can confirm the error and fix.
Forum: Plugins
In reply to: [Co-Authors Plus] Detecting number of Authors// Check if guest authors enabled if ( is_guest_authors_enabled() ) { // Get author(s) of post, assign letter value s if count greater than 1, else empty $S = 1 < count( get_coauthors() ) ? 's' : ''; // Set string with label, value of $S, and author name(s) with link $authors = "Author{$S} " . coauthors_posts_links( null, null, null, null, false ); // select output type and delete the other echo $authors; <or> return $authors; }Forum: Plugins
In reply to: [Co-Authors Plus] Help with guest author descriptionsThis is old, but I thought I reply. Maybe the problem solving method might help someone else tackle their own problems.
function coauthors_descriptions( $between = '', $betweenLast = '', $before = '', $after = '', $echo = true ) { $args = array( 'get_the_author_meta', 'tag', array( 'between' => $between, 'betweenLast' => $betweenLast, 'before' => $before, 'after' => $after ), 'description', $echo = false ); $description = coauthors__echo( $args ); // if empty return if ( ! $description ) { return; } echo $description; }// if return is required
function coauthors_descriptions( $between = '', $betweenLast = '', $before = '', $after = '', $echo = true ) { $args = array( 'get_the_author_meta', 'tag', array( 'between' => $between, 'betweenLast' => $betweenLast, 'before' => $before, 'after' => $after ), 'description', $echo = false ); $description = coauthors__echo( $args ); // if empty, return if ( ! $description ) { return; } // removes the last element in array, $echo = false array_pop( $args ); // adds new last element in array, $echo = true array_push( $args, true ); return coauthors__echo( $args ); }Forum: Plugins
In reply to: [Co-Authors Plus] Co-author Plus’s Guest Authors with ACFGuest Author “ID” are $post->ID. Guest author is a custom post-type and saved as post data. The author field’s are saved as post-meta.
If you are on the author archive page:
$post_id = get_queried_object_id(); $authorTwitter = get_field( 'authorTwitter', $post_id ); echo "<i class=\"social-icon fab fa-twitter fa-2x\"></i> <a href=\"$authorTwitter\">@twitter</a>";In your instance, for the social media fields, it would have been more efficient to have created the fields through a function that filters the guest author fields. That way the standard call for the author’s meta data would have included those additional social media fields. Now, you have to make two separate calls to get all the guest author’s data.
Forum: Plugins
In reply to: [Co-Authors Plus] How to utilize the coauthors_guest_author_fields filter?You’re missing the $groups argument. https://gist.github.com/danielbachhuber/ece7e8bb1a97ac4a1977
Follow the example in the link above. The below code is an expanded function to remove contact author fields, add additional contact author fields social media, and a phone field.add_filter( 'coauthors_guest_author_fields', 'edit_coauthors_guest_author_fields', 10, 2 ); function edit_coauthors_guest_author_fields( $fields_to_return, $groups ) { // Unset contact fields in Guest Author (bonus, not part of the original question) $remove = array( 'aim', 'yahooim', 'jabber' ); foreach ( $fields_to_return as $k => $value ) { if ( $value['key'] == in_array( $value['key'], $remove ) ) { unset( $fields_to_return[ $k ] ); } } // Add social fields to contact-info group (bonus, not part of the original question) $global_fields = array(); $socials = array( 'Twitter', 'LinkedIn', 'Instagram', 'YouTube', 'Facebook' ); foreach ( $socials as $social ) { $global_fields[] = array( 'key' => preg_replace( ' ', '_', strtolower( $social ) ), 'label' => $social, 'group' => 'contact-info', 'input' => 'url', ); } // Add phone field contact-info group $phone_number = 'Phone Number'; $global_fields[] = array( 'key' => preg_replace( ' ', '_', strtolower( $phone_number ) ), 'label' => $phone_number, 'group' => 'contact-info', 'input' => 'number', //number only or delete to use group's text type ); // Putting it all together $fields_to_return = array(); foreach ( $global_fields as $single_field ) { if ( in_array( $single_field['group'], $groups ) || 'all' === $groups[0] && 'hidden' !== $single_field['group'] ) { $fields_to_return[] = $single_field; } } }The function get_guest_author_fields( $groups = ‘all’ ) is found in class-coauthors-guest-authors.php
- This reply was modified 5 years, 1 month ago by backbone. Reason: Clarification of the additonal functions beyond the orginal question
Great!
It’s an invaluable lesson; initially work within the theme construction ( markup, navigation, etc.) when customizing the look and feel. Once you understand it, alterations become much quicker, more predictable and the most important; upgrading won’t be a nightmare.
The scroll-to jquery function called on the front page menu bar.
/template-parts/header/site-branding.phpif statement check three conditions
-is it twentyseventeen_is_frontpage() OR
-is the blog page set to front page AND
-if either is true, is there a nav menu with the location ‘top’?
-then show ( ‘icon’ => ‘arrow-right’ )The scroll-to jquery function
/assets/js/global.js-find a class value “menu-scroll-down”
$menuScrollDown = $body.find( ‘.menu-scroll-down’ )
-function$menuScrollDown.click( function( e ) { e.preventDefault(); $( window ).scrollTo( '#primary', { uration: 600 , offset: { top: menuTop - navigationOuterHeight } }); });Now that you know how to trigger the function and the target of the function, you can reuse. You only need the class name “menu-scroll-down” to fire function.
In Menu, screen options show class. Add the class name to the menu item.
On section page, you need to add the corresponding ID name at the location of the target. It can be as simple as, text mode, <h2 id=”your_anchor_name”>Text</h2> or use a transparent img.png, and add the id value to it, with less chance of being accidently deleted in an edit.Normally, a function is written to conditional check which navigation menu with the properly constructed target URI to load. You probably need to add the absolute URI domain.com/#anchor_name on the menu links.
The front-page panel for the section is missing ID name.
Are your using a third-party plugin or script for the smooth scroll-to effect? The browser inspector is showing the script constantly checking for a click all href with # and the target.
If you have some basic jQuery experience, modify global.js to create a full one-page navigation solution.
A usability suggestion, set the link for Online Ordering scroll-to the section on page, and add a “home” link to return to the front page. If I landed on that page and wanted to order, and clicked the link, it would reload the page over and over.
Update: I was able through SSH delete the cache and I am able to login.
I’m having the same issue. The problem is we have a redirect on the wp-admin / Login page to a front-end theme login page and it’s circular. I can’t even login to disable the cache.
Forum: Plugins
In reply to: [AutoChimp] Three dots, no "read more" linksTo have a “pretty url” simple link you change this
$postContent = wp_trim_words( $post->post_content, 55, $permalink );to something like this:
$postContent = wp_trim_words( $post->post_content, 55, ' [...] <a href="'.$permalink.'">Read More »</a>');