sandraqu
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: How to use WP_Query to filter by post excerptI need to filter post by post_excerpt contents. When I try using WP_Query as follows, I get all posts as a result in the resulting array. How can build an array that only contains post with post_excerpt = ‘this’ ?
This does not work:
$loop = new WP_Query( array( 'post_type' => 'portfolio', 'paged' => $paged, 'posts' => array( 'post_excerpt' => 'this' )) );
and this does not work:
$loop = new WP_Query( array( 'post_type' => 'portfolio', 'paged' => $paged, 'post_excerpt' => 'this' ) );
Forum: Fixing WordPress
In reply to: How to use WP_Query to filter by post excerptThanks for the pastebin tip. My language was inaccurate. The ‘skill’ is not a Custom Field. It’s customized, but not a Custom Field.
Furthermore, WP_Query seems to target one table: wp_post. I need to target the wp_post table, and a wp_term table
So I need to pass post_type= ‘portfolio’ and term_taxonomy_id = 11 and call two tables.
wp_post.post_type = portfolio and give me only those where wp_term.term_taxonomy_id = wp_post.ID.
For some reason, trying for post_excerpt = “ba” or even post_author = “3” will not filter. I don’t understand why. I tried isolating the posts I need to one author to see if a filter of that type would work.
Forum: Fixing WordPress
In reply to: How to use WP_Query to filter by post excerptI’m a newbie and am working with a theme that was created by someone who has an good understanding of WP. I am trying to apply my limited skills to the scripts. With your help I hope to get this right.
I don’t know where the custom field lives. I looked at the database, and it seems that there is a post_parent that has the same numbers for a series of posts, and I hope that corresponds to the “Skill” custom field.
An excerpt of the WP Query array follows. My attempt at filtering is not working:
[request] => SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'portfolio' AND ( wp_posts.post_status = 'publish') ORDER BY wp_posts.post_date DESC LIMIT 0, 10 [posts] =>
the array excerpt:
WP_Query Object ( [query_vars] => Array ( [post_type] => portfolio [paged] => 1 [posts[0]] => Array ( [post_excerpt] => ba ) [error] => [m] => 0 [p] => 0 [post_parent] => [subpost] => [subpost_id] => [attachment] => [attachment_id] => 0 [name] => [static] => [pagename] => [page_id] => 0 [second] => [minute] => [hour] => [day] => 0 [monthnum] => 0 [year] => 0 [w] => 0 [category_name] => [tag] => [cat] => [tag_id] => [author_name] => [feed] => [tb] => [comments_popup] => [meta_key] => [meta_value] => [preview] => [s] => [sentence] => [fields] => [category__in] => Array ( ) [category__not_in] => Array ( ) [category__and] => Array ( ) [post__in] => Array ( ) [post__not_in] => Array ( ) [tag__in] => Array ( ) [tag__not_in] => Array ( ) [tag__and] => Array ( ) [tag_slug__in] => Array ( ) [tag_slug__and] => Array ( ) [ignore_sticky_posts] => [suppress_filters] => [cache_results] => 1 [update_post_term_cache] => 1 [update_post_meta_cache] => 1 [posts_per_page] => 10 [nopaging] => [comments_per_page] => 50 [no_found_rows] => [order] => DESC ) [tax_query] => WP_Tax_Query Object ( [queries] => Array ( ) [relation] => AND ) [meta_query] => WP_Meta_Query Object ( [queries] => Array ( ) [relation] => ) [post_count] => 10 [current_post] => -1 [in_the_loop] => [comment_count] => 0 [current_comment] => -1 [found_posts] => 96 [max_num_pages] => 10 [max_num_comment_pages] => 0 [is_single] => [is_preview] => [is_page] => [is_archive] => [is_date] => [is_year] => [is_month] => [is_day] => [is_time] => [is_author] => [is_category] => [is_tag] => [is_tax] => [is_search] => [is_feed] => [is_comment_feed] => [is_trackback] => [is_home] => 1 [is_404] => [is_comments_popup] => [is_paged] => [is_admin] => [is_attachment] => [is_singular] => [is_robots] => [is_posts_page] => [is_post_type_archive] => [query_vars_hash] => d93ccb2ea312a6d1 [query_vars_changed] => [thumbnails_cached] => [query] => Array ( [post_type] => portfolio [paged] => 1 [posts[0]] => Array ( [post_excerpt] => ba ) ) [request] => SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'portfolio' AND ( wp_posts.post_status = 'publish') ORDER BY wp_posts.post_date DESC LIMIT 0, 10 [posts] => Array ( [0] => stdClass Object ( [ID] => 696 [post_author] => 1 [post_date] => 2012-05-01 18:51:28 [post_date_gmt] => 2012-05-01 18:51:28 [post_content] => [post_title] => White Pearl, Rock [post_excerpt] => ba [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => white-pearl-rock [to_ping] => [pinged] => [post_modified] => 2012-05-01 18:51:28 [post_modified_gmt] => 2012-05-01 18:51:28 [post_content_filtered] => [post_parent] => 0 [guid] => https://mydomain.com/dev/?post_type=portfolio&p=696 [menu_order] => 0 [post_type] => portfolio [post_mime_type] => [comment_count] => 0 [filter] => raw ) [1] => stdClass Object ( [ID] => 723 [post_author] => 1 [post_date] => 2012-05-01 17:12:15 [post_date_gmt] => 2012-05-01 17:12:15 [post_content] => New floor and steps, State, CA. [post_title] =>
Forum: Fixing WordPress
In reply to: How to use WP_Query to filter by post excerptHi. I have a portfolio, and wish to show only posts from the “portfolio” with a certain “skill” (custom instead of category), on a page.
this loop is getting called from a page template, and i cannot see the “skill” in the array, thus I added a code in the excerpt field, and am trying to target that field in the array to build an array with only items that have ‘ba’ in the excerpt field.
Is that helpful?
For anyone wanting to do this, here is what I did to get it working. If you can improve this, feel free. I’m not a lithe PHP Developer.
I added this conditional into core.php about line 454.
if (strpos($tweet, '%E') !== false) { // Get post excerpt $post = get_post( $id ); $post_exc = $post->post_excerpt; unset( $post ); // Replace %E with post excerpt $tweet = str_replace('%E', $post_exc, $tweet); }
And, in WP, called %E in the Settings for YOURLS WordPress to Plugin Tweet message field: #in %E %U
Obviously the “#in” is there so that the Tweet posts to LinkedIn.
anyone?
I’m trying to use YOURLS to Twitter (WordPress plugin) to output the excerpt.
The plugin’s instructions suggest
%F{something}: custom post field ‘something’. See get_post_meta().
WordPress informs
<?php $meta_values = get_post_meta($post_id, $key, $single); ?>
Where $key is a string “(required) A string containing the name of the meta value you want.”
The HTML has
<meta name="description" content="this is my excerpt" />
Where the description meta has the excerpt’s content.
I tried using
#in %F{description} %U
and got “#in bit.ly/7493d0e”. How can I get the excerpt to print? This is the php interpreting that %F
if( preg_match_all( '/%F\{([^\}]+)\}/', $tweet, $matches ) ) { foreach( $matches[1] as $match ) { $field = get_post_meta( $id, $match, true ); $tweet = str_replace('%F{'.$match.'}', $field, $tweet); } unset( $matches ); }
Alright. The plugin stopped working and I have no idea how or why since it was the last plugin installed. This is not related to deleting the Canvas URL. It stopped working on its own.
What I’m wondering is how do you get the “tokens”? Clicking “Grant SFC Permissions” button doesn’t do anything.
I was getting that error, and my plugin is now working having followed two set of instructions. I don’t know which of my actions resolved the issue, but here is what I did:
After following a set of about 10 steps that, sadly, I can not find the URL for, I got rid of the 102. Those particular instructions stated to add a “Canvas URL”. This got rid of the 102, but gave me other errors— it produced a blurb in the “Facebook Publisher” box right of my post while in edit.
I then followed these instructions and wallah! it works. These instructions specify to go to your FB App page and click “Add to My Page”. They also clarify which URL to add in the “Website URL” field of the App settings.
https://solutionsbyheidi.com/2011/10/10/using-simple-facebook-connect/
This is the way my app is currently setup and working. I hope you find it helpful:
Basic info
Display Name: This Useful App
Namespace: thisusefulapp
Contact: [email protected]
App Domain: < this is empty >Select how your app integrates with Facebook
Website
Site URL: https://myblogsdomain.comApp on FB
Canvas URL: https://apps.facebook.com/thisusefulapp/
Secure Canvas URL: https://apps.facebook.com/thisusefulapp/