Difference between revisions of "LoopBuddy"

From iThemes Codex
Jump to: navigation, search
 
(73 intermediate revisions by 11 users not shown)
Line 1: Line 1:
'''Release date:''' TBA
+
__NOTOC__
  
==Internal Workings==
+
[[File:Loopbuddy300.png|Loopbuddy300.png|300px|link=|center]]
  
==Sample Layouts and Queries==
+
<br />
  
[[File:Loopbuddy export.zip]]
+
LoopBuddy is a tool that overwrites a WordPress Loop using a combination of a custom query and a custom layout.  You can also create your own Loops using the LoopBuddy shortcode and LoopBuddy widget.
  
==Shortcode==
+
<div class="exchange-home-list">
 +
==LoopBuddy Basics== __NOEDITSECTION__
 +
*[[Query_Editor|Query Editor]]
 +
*[[Layout_Editor|Layout Editor]]
 +
*[[LoopBuddy_Global_Settings|Global Settings]]
 +
*[[Import/Export|Import/Export]]
 +
*[[LoopBuddy Widget|LoopBuddy Widget]]
 +
*[[LoopBuddy Shortcode|LoopBuddy Shortcode]]
 +
</div>
  
The LoopBuddy shortcode takes two attributes:  a Query ID and a Layout ID.
+
<div class="exchange-home-list">
 +
==LoopBuddy Advanced== __NOEDITSECTION__
 +
*[[The_Loop_Standard|The Loop Standard]]
 +
**[[The_Loop_Explained|The Loop Explained]]
 +
*[[Modifying_a_Theme_to_Use_LoopBuddy|Modifying a Theme to Use LoopBuddy]]
 +
**[[Example_of_TwentyTen_Using_the_Loop_Standard|Example of TwentyTen Using the Loop Standard]]
 +
**[[Showing_LoopBuddy_Theme_Support|Showing LoopBuddy Theme Support]]
 +
**[[Adding_the_Dynamic_Loop_Function_to_Your_Theme|Adding the Dynamic Loop Function to Your Theme]]
 +
*[[Convert_Any_Theme_to_Support_LoopBuddy|Convert Any Theme to Support LoopBuddy]]
 +
**[[Two_Key_Code_Snippets_that_Support_LoopBuddy|Two Key Code Snippets that Support LoopBuddy]]
 +
**[[Wrap_the_Original_Loop_with_a_Conditional_Tag|Wrap the Original Loop with a Conditional Tag]]
 +
*[[Other_Notes_About_Conversions|Other Notes About Conversions]]
 +
</div>
  
Simply insert the shortcode into a post or page:
+
<div class="exchange-home-list">
 +
==LoopBuddy Downloads== __NOEDITSECTION__
 +
*[[Example_TwentyEleven_Theme|Example TwentyEleven Theme]]
 +
*[[Example_Layout_Tag|Example Layout Tag]]
 +
*[[Example_Queries/Layous|Example Queries/Layouts]]
 +
</div>
  
<pre class='brush:php'>
+
<div class="exchange-home-list">
[loopbuddy query_id='0' layout_id='0']
+
==LoopBuddy Query== __NOEDITSECTION__
</pre>
+
*[[LoopBuddy_Query_Overview|Overview]]
 +
*[[Advanced_Meta_Queries|Advanced Meta Queries]]
 +
*[[Advanced_Taxonomy_Queries|Advanced Taxonomy Queries]]
 +
</div>
  
==Hooks==
+
<div class="exchange-home-list">
 +
==Hooks== __NOEDITSECTION__
 +
*[[Hooks_Overview|Overview]]
 +
*[[Creating_a_New_Custom_Tag|Creating a New Custom Tag]]
 +
*[[Creating_a_New_Custom_Tag_Item|Creating a New Custom Tag Item]]
 +
*[[Callback_Function_for_Displaying_the_Tag|Callback Function for Displaying the Tag - pb_loopbuddy_tag_callback-(tag_name)]]
 +
*[[Rendering_the_Tag_on_the_Front-end|Rendering the Tag on the Front-end - pb_loopbuddy_render-(tag_name)]]
 +
*[[Ignoring_Post_Types_in_the_Layout_Editor|Ignoring Post Types in the Layout Editor]]
 +
</div>
  
LoopBuddy allows you to create custom tags for the Layout editor.  This is advanced functionality, so please don't attempt these steps if you are not intimately familiar with PHP and how LoopBuddy operates.
+
<div class="exchange-home-list">
 +
==Shortcodes== __NOEDITSECTION__
 +
*[[Shortcodes_Overview|Overview]]
 +
*[[Current_Limitations_(LoopBuddy_1.2.X_and_Earlier)|Current Limitations (LoopBuddy 1.2.X and Earlier)]]
 +
*[[Add_a_Shortcode_with_Parameters_to_a_Layout|Add a Shortcode with Parameters to a Layout]]
 +
*[[Add_a_Shortcode_with_Parameters_in_the_Pre-Loop_or_Post-loop_Fields|Add a Shortcode with Parameters in the Pre-Loop or Post-Loop Fields]]
 +
*[[Show_Category/Taxonomy_Description_on_NON-Archive_Pages_via_Shortcode|Show Category/Taxonomy Description on NON-Archive Pages via Shortcode]]
 +
*[[Show_Custom_Page_Title_for_Same_LoopBuddy_Layout_on_Different_Pages_via_Shortcode|Show Custom Page Title for Same LoopBuddy Layout on Different Pages via Shortcode]]
 +
*[[Add_Previous_and_Next_Post_Links_on_Single_Post_Pages|Add Previous and Next Post Links on Single Post Pages]]
 +
*[[Add_Previous_and_Next_Title_Links_on_Single_Post_Pages|Add Previous and Next Title Links on Single Post Pages]]
 +
*[[Add_the_Post_Author_Avatar|Add the Post Author Avatar]]
 +
*[[Add_Navigation_from_the_WP-PageNavi_Plugin|Add Navigation from the WP-PageNavi Plugin]]
 +
*[[Add_a_Link_to_Post_Comments_in_the_Post_List_(Archive_Page)|Add a Link to Post Comments in the Post List (Archive Page)]]
 +
*[[Add_Post_Comments_to_a_Single_Post_or_to_Posts_in_the_Post_List_(Archive_Page)|Add Post Comments to a Single Post or to Posts in the Post LIst (Archive Page)]]
 +
*[[Add_Comment_Form_to_a_Single__Post_or_to_Posts_in_the_Post_List_(Archive_Page)|Add Comment Form to a Single Post or to Posts in the Post List (Archive Page)]]
 +
*[[Add_Content_from_a_Custom_Field_to_a_Layout|Add Content from a Custom Field to a Layout]]
 +
*[[Add_Number_of_Post_Views|Add Number of Post Views]]
 +
*[[Add_Number_of_Comments|Add Number of Comments]]
 +
*[[Add_Archive_Page_Headers|Add Archive or Search page Header]]
 +
</div>
  
To create the custom tag, you must use the following hooks.
+
<div class="exchange-home-list">
 +
==External Plugins Compatibility== __NOEDITSECTION__
 +
*[[External_Plugins_Compatibility_Overview|Overview]]
 +
*[[Custom_Post_Types|Custom Post Types]]
 +
*[[Page_Navigation|Page Navigation]]
 +
*[[Customize_Excerpts|Customize Excerpts]]
 +
</div>
  
===Creating a new Custom Tag===
+
<div class="exchange-home-list">
 +
==FAQs== __NOEDITSECTION__
 +
*[[Sort_Custom_Field_Values_by_Meta_Value_(Character_or_Numeric)|Sort Custom Field Values by Meta Value (Character or Numeric)]]
 +
*[[LoopBuddy_Does_Not_Work_on_Static_Posts_Page|LoopBuddy Does Not Work on Static Posts Page]]
 +
*[[Make_a_Custom_Field_(or_Amost_Anything)_Clickable|Make a Custom Field (or Almost Anything) Clickable]]
 +
*[[Search_Within_a_LoopBuddy_Query|Search Within a LoopBuddy Query]]
 +
*[[Change_OLDER_POSTS_and_NEWER_POSTS_Pagination_Text|Change OLDER POSTS and NEW POSTS Pagination Text]]
 +
</div>
  
<pre class="brush:php">
+
<div class="exchange-home-list">
<?php
+
==Video Tutorials and Tips== __NOEDITSECTION__
add_filter( 'pb_loopbuddy_custom_tags', 'my_custom_tag_add' );
+
*[[Video_Tutorials_and_Tips_Overview|Overview]]
function my_custom_tag_add( $custom_tags ) {
+
*[[LoopBuddy_Full_1_Hour_Webinar|LoopBuddy Full 1 Hour Webinar]]
//Always return $custom_tags
+
*[http://ithemes.com/forum/index.php?/topic/18160-loop-buddy-placement/#p85184 Show custom static homepage content and 3 latest blog excerpts under it]
$custom_tags[ 'start_wrap' ] = array(
+
</div>
'My Tag Label',
 
array(
 
'wrap' => 'div',
 
'custom_class' => 'default class'
 
)
 
);
 
return $custom_tags;
 
} //end my_custom_tag_add
 
 
//Start off with the tag name, give the tag a label, and pass it which items it supports (all should ideally contain the 'wrap' and 'custom_class' items
 
?>
 
</pre>
 
  
Here are some built in tag items that you can choose from:
+
<div class="exchange-home-list">
 +
==Additional Resources== __NOEDITSECTION__
 +
*[http://ithemes.com/purchase/backupbuddy/ Purchase BackupBuddy]
 +
*[http://ithemes.com/tutorials/ iThemes Tutorials]
 +
*[http://ithemes.com/ iThemes.com]
 +
*[http://ithemes.com/forum/ Support Forums]
 +
</div>
  
* link_text
+
<br />
* custom_url
+
[[:Plugins|← Back to Plugin Codex Home]]
* custom_class
 
* link_title
 
* before_text
 
* after_text
 
* meta_key
 
* max_width
 
* max_height
 
* shortcode
 
* author_link_destination
 
* user_profile
 
* permalink
 
* attachment_link_display
 
* separator
 
* text
 
* date_format
 
* comment_number_zero
 
* comment_number_one
 
* comment_number_more
 
* post_date
 
* bloginfo
 
* content_more
 
* url_display
 
* image_size
 
 
 
==Custom Tag Example==
 
We have created an example plugin to add a custom tag.
 
 
 
Check out the LoopBuddy Marquee Plugin: [[File:Loopbuddy_marquee.zip]] as an example of creating custom tags.
 
 
 
===Creating a new custom tag item===
 
 
 
<pre class='brush:php'>
 
<?php
 
add_filter( 'pb_loopbuddy_tag_items', 'my_custom_item_add' );
 
function my_custom_item_add( $loopbuddy_items ) {
 
//Always return $loopbuddy_items
 
 
$loopbuddy_items[ 'my_custom_item' ] = array(
 
'function' => 'callback_function',
 
'args' => array(
 
'label' => __( 'Link Text', 'LION' ),
 
'tip' => __( 'Optional text for link.  Leave blank to use link as the text.', 'LION' ),
 
'options' => array( 'option1', 'option2' )
 
)
 
);
 
return $loopbuddy_items;
 
} //end my_custom_item_add
 
 
 
/* $settings are the arguments passed for the tag item and looks like this
 
[label] => HTML Wrapper
 
    [tip] => Choose which HTML element to wrap around the item
 
    [options] => Array
 
        (
 
            [0] => none
 
            [1] => span
 
            [2] => div
 
            [3] => p
 
            [4] => h1
 
            [5] => h2
 
            [6] => h3
 
            [7] => h4
 
            [8] => h5
 
            [9] => h6
 
        )
 
 
 
    [key] => wrap
 
    [settings] => Array
 
        (
 
            [image_size] => thumbnail
 
            [max_width] =>
 
            [max_height] =>
 
            [wrap] => p
 
            [before_text] =>
 
            [after_text] =>
 
            [custom_url] =>
 
            [custom_class] => attachment
 
            [tag] => wp_get_attachment_image
 
        )
 
 
 
)
 
*/
 
function callback_function( $settings ) {
 
$defaults = array(
 
'key' => '',
 
'label' => '',
 
'tip' => false,
 
'settings' => array(),
 
'options' => array()
 
);
 
extract( wp_parse_args( $settings, $defaults ) );
 
//Output HTML for the item
 
} //end callback_function
 
 
 
?>
 
</pre>
 
 
 
===Callback function for displaying the tag - pb_loopbuddy_tag_callback-{tag_name}===
 
<pre class='brush:php'>
 
<?php
 
/*$settings contains the tag items and the tag item's value
 
Example
 
Array
 
(
 
    [image_size] => thumbnail
 
    [max_width] =>
 
    [max_height] =>
 
    [wrap] => p
 
    [before_text] =>
 
    [after_text] =>
 
    [custom_url] =>
 
    [custom_class] => attachment
 
    [tag] => wp_get_attachment_image
 
)
 
*/
 
 
//Add header code
 
add_action( 'pb_loopbuddy_tag_header-mytagname', 'my_custom_tag_header' );
 
function my_custom_tag_header( $settings ) {
 
echo "my header, notes, or other code";
 
//Render your tag based on its settings
 
} //end my_custom_tag_header
 
 
 
//Add footer code
 
add_action( 'pb_loopbuddy_tag_footer-mytagname', 'my_custom_tag_footer' );
 
function my_custom_tag_footer( $settings ) {
 
echo "my footer, notes, or other code";
 
//Render your tag based on its settings
 
} //end my_custom_tag_header
 
 
 
add_filter( 'pb_loopbuddy_tag_supports-mytagname', 'my_custom_tag_supports' );
 
//Return an array of what tag items the tag supports
 
function my_custom_tag_supports( $support_tag_items ) {
 
return array( 'wrap', 'link_text', 'before_text', 'after_text', 'custom_class' );
 
//Render your tag based on its settings
 
} //end my_custom_tag_supports
 
?>
 
</pre>
 
 
 
===Rendering the Tag on the Front-end - pb_loopbuddy_render-{tag_name}===
 
 
 
<pre class="brush:php">
 
<?php
 
add_filter( 'pb_loopbuddy_render-mytagname', 'mytagname_frontend', 10, 2 );
 
function mytagname_frontend( $post_object, $tag_items ) {
 
/* $tag_items look like this
 
(
 
    [wrap] => none
 
    [link_text] => Edit Post
 
    [before_text] =>
 
    [after_text] =>
 
    [custom_url] =>
 
    [custom_class] =>
 
    [tag] => edit_post_link
 
)
 
*/
 
$return = false; //Populate the $return variable
 
$return = pluginbuddy_loopbuddy_render_slotitems::get_output( $return, $post_object, $tag_items, true ); //The last argument is skip_before text
 
return $return;
 
} //end mytagname_frontend
 
?>
 
</pre>
 
 
 
==Suggestions / Bugs==
 
# SUGGESTION - Currently when you add multiple tags to the same line in the Layout Editor, it displays them right next to each other WITHOUT a space.  It would be beneficial if all tags automatically have a space after them so that users don't have to go add spaces themselves.
 
# The use of the "Use Current Post or Page ID"  is a VERY important setting for LoopBuddy, maybe if we add an additional explanation or example to the help area.
 
 
 
==Additional Resources==
 
# [http://pluginbuddy.com/purchase/backupbuddy/ Purchase BackupBuddy]
 
 
 
# [http://pluginbuddy.com/tutorials/ PluginBuddy Tutorials]
 
# [http://pluginbuddy.com/ PluginBuddy.com]
 
# [http://pluginbuddy.com/support/ Support Forums]
 
 
 
[[Category:PluginBuddy]]
 

Latest revision as of 10:43, 2 August 2014


Loopbuddy300.png


LoopBuddy is a tool that overwrites a WordPress Loop using a combination of a custom query and a custom layout. You can also create your own Loops using the LoopBuddy shortcode and LoopBuddy widget.


← Back to Plugin Codex Home