SlideShare a Scribd company logo
1 of 10
Getting different sets of
posts in your theme
Roman Rus
@RomSocial
www.websitesupgrade.com
The Main Loop
The loop:
while (have_posts()) :
the_post();
the_permalink();
the_post_thumbnail();
the_content();
the_excerpt();
the_time();
the_author();
comments_template( );
endwhile;
query_posts()
The loop:
while (have_posts()) :
the_post();
...
endwhile;
Second time same loop:
rewind_posts();
while (have_posts()) :
the_post(); ...
endwhile;
Run a different loop:
query_posts(
'category_name=cat2&
posts_per_page=10');
while (have_posts()) :
the_post(); ...
endwhile;
wp_reset_query();
get_posts()
Most commented posts:
$args = array(
'numberposts' => 4,
'orderby' => ‘comment_count',
'order' => 'DESC');
$theposts = get_posts( $args);

If in functions.php etc.:
global $post;
foreach($theposts as $post) :
setup_postdata($post);
the_permalink();
the_post_thumbnail();
the_title();
...
endforeach;

wp_reset_postdata();
Most commented posts
Featured posts
Most recent posts from
selected categories, then
second most recent
posts, etc.
Most read posts

Most shared on social
media posts

List of subcategories with
images
get_posts( $args);
get_posts parameters:
$args = array(
'numberposts‘ => 1,
'posts_per_page' => 5,
'offset' => 0,
'category' => '',
'orderby' => '',
'order' => 'DESC',
'include' => '',
'exclude' => '',
'meta_key' => '',
'meta_value' => '',
'post_type' => 'post',
'post_mime_type' => '',
'post_parent' => '',
'post_status' => 'publish',
'suppress_filters' => true );
$theposts = get_posts( $args);

ORDERBY options:

'none'
'ID'
'author'
'title'
'date'
'modified'
'parent'
'rand'
'comment_count'
'menu_order'
'meta_value' // 'meta_key‘
'meta_value_num' // 'meta_key‘
'meta_query' => array(
array( 'key' => 'featured',
'value' => 'yes', ));
'tax_query' => array(
array( 'taxonomy' => 'genre',
'field' => 'slug',
'terms' => 'jazz' ) )
How it is done?

Most read posts

Most commented posts

Featured posts

Most recent post, second
most recent post, etc.
from individual
categories

Plugin: Meta Box

Define custom field,
++ on single post views
or
Plugin: WP-PostViews

Most shared on social
media posts
Plugin: Most Shared Posts
Name of meta tag
'meta_key' =>
'_msp_total_shares'

Sort by
'comment_count'
or 'date' (default)
use
'offset', 'category',
'numberposts'

Sort by 'date' (default)
with filter
'meta_key' => '_fp',
'meta_value' => '1',

Sort by 'meta_value'
or 'meta_value_num'
Sub-categories listing?
Plugin: Categories Images
z_taxonomy_image_url();

$args = array(
'type' => 'post',

Plugin: Taxonomy TinyMCE (not working?)

'child_of' => 0,

Plugin: WP Category Permalink (for SEO)

'parent' => '',
'orderby' => 'name',

$categories= get_categories($args);
foreach ($categories as $category) :
$imgurl = z_taxonomy_image_url(

$category->term_id);
get_category_link( $category->term_id);
echo( $category->slug);
echo( $category->cat_name;);

endforeach;

'order' => 'ASC',
'hide_empty' => 1,
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'number' => '',

'taxonomy' => 'category',
'pad_counts' => false );
Thumbnails
Plugin: Categories Images
Plugin: Regenerate Thumbnails
Plugin: Thumbnail Upscale
In functions.php add different sizes for thumbnails:
add_image_size(‘n_toprow', 164, 105, true);
add_image_size(‘n_mainblog', 300, 260, true);
..
In the loop etc. add:
the_post_thumbnail( ' n_toprow' );

Bad hack for categories:
$imgurl = z_taxonomy_image_url($category->term_id);
$imgurlmod = str_replace ( '.jpg' , '-300x260.jpg' , $imgurl );
Thank you for your attention!
Questions?
Roman Rus
@RomSocial
www.websitesupgrade.com

More Related Content

What's hot

[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018Adam Tomat
 
You Don't Know Query (WordCamp Netherlands 2012)
You Don't Know Query (WordCamp Netherlands 2012)You Don't Know Query (WordCamp Netherlands 2012)
You Don't Know Query (WordCamp Netherlands 2012)andrewnacin
 
Web2py Code Lab
Web2py Code LabWeb2py Code Lab
Web2py Code LabColin Su
 
Difference between mysql_fetch_array and mysql_fetch_assoc in PHP
Difference between mysql_fetch_array and mysql_fetch_assoc in PHPDifference between mysql_fetch_array and mysql_fetch_assoc in PHP
Difference between mysql_fetch_array and mysql_fetch_assoc in PHPVineet Kumar Saini
 
Creatively creating custom post types! word sesh2
Creatively creating custom post types!  word sesh2Creatively creating custom post types!  word sesh2
Creatively creating custom post types! word sesh2techvoltz
 
Drupal vs WordPress
Drupal vs WordPressDrupal vs WordPress
Drupal vs WordPressWalter Ebert
 
Views Style Plugins
Views Style PluginsViews Style Plugins
Views Style Pluginsmwrather
 
Python Templating Engine - Intro to Jinja
Python Templating Engine - Intro to JinjaPython Templating Engine - Intro to Jinja
Python Templating Engine - Intro to JinjaEueung Mulyana
 
Drupal 8 Sample Module
Drupal 8 Sample ModuleDrupal 8 Sample Module
Drupal 8 Sample Moduledrubb
 
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway ichikaway
 
Drupal 8: Routing & More
Drupal 8: Routing & MoreDrupal 8: Routing & More
Drupal 8: Routing & Moredrubb
 
[Bucharest] Your intents are dirty, droid!
[Bucharest] Your intents are dirty, droid![Bucharest] Your intents are dirty, droid!
[Bucharest] Your intents are dirty, droid!OWASP EEE
 
Rails' Next Top Model
Rails' Next Top ModelRails' Next Top Model
Rails' Next Top ModelAdam Keys
 
Getting Creative with WordPress Queries
Getting Creative with WordPress QueriesGetting Creative with WordPress Queries
Getting Creative with WordPress QueriesDrewAPicture
 
Caching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment CachingCaching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment CachingErick Hitter
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretssmueller_sandsmedia
 
前端MVC 豆瓣说
前端MVC 豆瓣说前端MVC 豆瓣说
前端MVC 豆瓣说Ting Lv
 

What's hot (20)

[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018
 
You Don't Know Query (WordCamp Netherlands 2012)
You Don't Know Query (WordCamp Netherlands 2012)You Don't Know Query (WordCamp Netherlands 2012)
You Don't Know Query (WordCamp Netherlands 2012)
 
Web2py Code Lab
Web2py Code LabWeb2py Code Lab
Web2py Code Lab
 
Difference between mysql_fetch_array and mysql_fetch_assoc in PHP
Difference between mysql_fetch_array and mysql_fetch_assoc in PHPDifference between mysql_fetch_array and mysql_fetch_assoc in PHP
Difference between mysql_fetch_array and mysql_fetch_assoc in PHP
 
Creatively creating custom post types! word sesh2
Creatively creating custom post types!  word sesh2Creatively creating custom post types!  word sesh2
Creatively creating custom post types! word sesh2
 
Drupal vs WordPress
Drupal vs WordPressDrupal vs WordPress
Drupal vs WordPress
 
Advanced Querying with CakePHP 3
Advanced Querying with CakePHP 3Advanced Querying with CakePHP 3
Advanced Querying with CakePHP 3
 
Views Style Plugins
Views Style PluginsViews Style Plugins
Views Style Plugins
 
Python Templating Engine - Intro to Jinja
Python Templating Engine - Intro to JinjaPython Templating Engine - Intro to Jinja
Python Templating Engine - Intro to Jinja
 
Drupal 8 Sample Module
Drupal 8 Sample ModuleDrupal 8 Sample Module
Drupal 8 Sample Module
 
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
 
Drupal 8: Routing & More
Drupal 8: Routing & MoreDrupal 8: Routing & More
Drupal 8: Routing & More
 
Ch8(oop)
Ch8(oop)Ch8(oop)
Ch8(oop)
 
[Bucharest] Your intents are dirty, droid!
[Bucharest] Your intents are dirty, droid![Bucharest] Your intents are dirty, droid!
[Bucharest] Your intents are dirty, droid!
 
Separation of concerns - DPC12
Separation of concerns - DPC12Separation of concerns - DPC12
Separation of concerns - DPC12
 
Rails' Next Top Model
Rails' Next Top ModelRails' Next Top Model
Rails' Next Top Model
 
Getting Creative with WordPress Queries
Getting Creative with WordPress QueriesGetting Creative with WordPress Queries
Getting Creative with WordPress Queries
 
Caching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment CachingCaching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment Caching
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secrets
 
前端MVC 豆瓣说
前端MVC 豆瓣说前端MVC 豆瓣说
前端MVC 豆瓣说
 

Similar to Wordpress multiple loops

Mastering Custom Post Types - WordCamp Atlanta 2012
Mastering Custom Post Types - WordCamp Atlanta 2012Mastering Custom Post Types - WordCamp Atlanta 2012
Mastering Custom Post Types - WordCamp Atlanta 2012Mike Schinkel
 
Building a Portfolio With Custom Post Types
Building a Portfolio With Custom Post TypesBuilding a Portfolio With Custom Post Types
Building a Portfolio With Custom Post TypesAlex Blackie
 
MTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new APIMTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new APISix Apart KK
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress WebsitesKyle Cearley
 
Dig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoDig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoMohamed Mosaad
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress sitereferences
 
WordPress Cuztom Helper
WordPress Cuztom HelperWordPress Cuztom Helper
WordPress Cuztom Helperslicejack
 
Can WordPress really do that? A case study of vierderduer.no
Can WordPress really do that? A case study of vierderduer.noCan WordPress really do that? A case study of vierderduer.no
Can WordPress really do that? A case study of vierderduer.noMorten Rand-Hendriksen
 
Custom content types & custom taxonomies in wordpress
Custom content types & custom taxonomies in wordpressCustom content types & custom taxonomies in wordpress
Custom content types & custom taxonomies in wordpressstimasoft
 
Custom Post Types and Meta Fields
Custom Post Types and Meta FieldsCustom Post Types and Meta Fields
Custom Post Types and Meta FieldsLiton Arefin
 
You don’t know query - WordCamp UK Edinburgh 2012
You don’t know query - WordCamp UK Edinburgh 2012You don’t know query - WordCamp UK Edinburgh 2012
You don’t know query - WordCamp UK Edinburgh 2012l3rady
 
Digging into WordPress custom fields - WordCamp Brno 2017
Digging into WordPress custom fields - WordCamp Brno 2017Digging into WordPress custom fields - WordCamp Brno 2017
Digging into WordPress custom fields - WordCamp Brno 2017Magdalena Paciorek
 
WP_Query, pre_get_posts, and eliminating query_posts()
WP_Query, pre_get_posts, and eliminating query_posts()WP_Query, pre_get_posts, and eliminating query_posts()
WP_Query, pre_get_posts, and eliminating query_posts()Erick Hitter
 
Extending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post TypesExtending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post TypesUtsav Singh Rathour
 
Intermediate SQL with Ecto - LoneStar ElixirConf 2018
Intermediate SQL with Ecto - LoneStar ElixirConf 2018Intermediate SQL with Ecto - LoneStar ElixirConf 2018
Intermediate SQL with Ecto - LoneStar ElixirConf 2018wreckoning
 
Stepping Into Custom Post Types
Stepping Into Custom Post TypesStepping Into Custom Post Types
Stepping Into Custom Post TypesK.Adam White
 
WordPress London 16 May 2012 - You don’t know query
WordPress London 16 May 2012 - You don’t know queryWordPress London 16 May 2012 - You don’t know query
WordPress London 16 May 2012 - You don’t know queryl3rady
 
WordPress as an application framework
WordPress as an application frameworkWordPress as an application framework
WordPress as an application frameworkDustin Filippini
 
Pyconie 2012
Pyconie 2012Pyconie 2012
Pyconie 2012Yaqi Zhao
 

Similar to Wordpress multiple loops (20)

Mastering Custom Post Types - WordCamp Atlanta 2012
Mastering Custom Post Types - WordCamp Atlanta 2012Mastering Custom Post Types - WordCamp Atlanta 2012
Mastering Custom Post Types - WordCamp Atlanta 2012
 
Building a Portfolio With Custom Post Types
Building a Portfolio With Custom Post TypesBuilding a Portfolio With Custom Post Types
Building a Portfolio With Custom Post Types
 
MTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new APIMTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new API
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress Websites
 
Dig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoDig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup Cairo
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress site
 
WordPress Cuztom Helper
WordPress Cuztom HelperWordPress Cuztom Helper
WordPress Cuztom Helper
 
Can WordPress really do that? A case study of vierderduer.no
Can WordPress really do that? A case study of vierderduer.noCan WordPress really do that? A case study of vierderduer.no
Can WordPress really do that? A case study of vierderduer.no
 
Custom content types & custom taxonomies in wordpress
Custom content types & custom taxonomies in wordpressCustom content types & custom taxonomies in wordpress
Custom content types & custom taxonomies in wordpress
 
Custom Post Types and Meta Fields
Custom Post Types and Meta FieldsCustom Post Types and Meta Fields
Custom Post Types and Meta Fields
 
You don’t know query - WordCamp UK Edinburgh 2012
You don’t know query - WordCamp UK Edinburgh 2012You don’t know query - WordCamp UK Edinburgh 2012
You don’t know query - WordCamp UK Edinburgh 2012
 
Digging into WordPress custom fields - WordCamp Brno 2017
Digging into WordPress custom fields - WordCamp Brno 2017Digging into WordPress custom fields - WordCamp Brno 2017
Digging into WordPress custom fields - WordCamp Brno 2017
 
WP_Query, pre_get_posts, and eliminating query_posts()
WP_Query, pre_get_posts, and eliminating query_posts()WP_Query, pre_get_posts, and eliminating query_posts()
WP_Query, pre_get_posts, and eliminating query_posts()
 
Extending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post TypesExtending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post Types
 
Intermediate SQL with Ecto - LoneStar ElixirConf 2018
Intermediate SQL with Ecto - LoneStar ElixirConf 2018Intermediate SQL with Ecto - LoneStar ElixirConf 2018
Intermediate SQL with Ecto - LoneStar ElixirConf 2018
 
Stepping Into Custom Post Types
Stepping Into Custom Post TypesStepping Into Custom Post Types
Stepping Into Custom Post Types
 
WordPress London 16 May 2012 - You don’t know query
WordPress London 16 May 2012 - You don’t know queryWordPress London 16 May 2012 - You don’t know query
WordPress London 16 May 2012 - You don’t know query
 
WordPress as an application framework
WordPress as an application frameworkWordPress as an application framework
WordPress as an application framework
 
Pyconie 2012
Pyconie 2012Pyconie 2012
Pyconie 2012
 
php2.pptx
php2.pptxphp2.pptx
php2.pptx
 

Recently uploaded

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Wordpress multiple loops

  • 1. Getting different sets of posts in your theme Roman Rus @RomSocial www.websitesupgrade.com
  • 2. The Main Loop The loop: while (have_posts()) : the_post(); the_permalink(); the_post_thumbnail(); the_content(); the_excerpt(); the_time(); the_author(); comments_template( ); endwhile;
  • 3. query_posts() The loop: while (have_posts()) : the_post(); ... endwhile; Second time same loop: rewind_posts(); while (have_posts()) : the_post(); ... endwhile; Run a different loop: query_posts( 'category_name=cat2& posts_per_page=10'); while (have_posts()) : the_post(); ... endwhile; wp_reset_query();
  • 4. get_posts() Most commented posts: $args = array( 'numberposts' => 4, 'orderby' => ‘comment_count', 'order' => 'DESC'); $theposts = get_posts( $args); If in functions.php etc.: global $post; foreach($theposts as $post) : setup_postdata($post); the_permalink(); the_post_thumbnail(); the_title(); ... endforeach; wp_reset_postdata();
  • 5. Most commented posts Featured posts Most recent posts from selected categories, then second most recent posts, etc. Most read posts Most shared on social media posts List of subcategories with images
  • 6. get_posts( $args); get_posts parameters: $args = array( 'numberposts‘ => 1, 'posts_per_page' => 5, 'offset' => 0, 'category' => '', 'orderby' => '', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_mime_type' => '', 'post_parent' => '', 'post_status' => 'publish', 'suppress_filters' => true ); $theposts = get_posts( $args); ORDERBY options: 'none' 'ID' 'author' 'title' 'date' 'modified' 'parent' 'rand' 'comment_count' 'menu_order' 'meta_value' // 'meta_key‘ 'meta_value_num' // 'meta_key‘ 'meta_query' => array( array( 'key' => 'featured', 'value' => 'yes', )); 'tax_query' => array( array( 'taxonomy' => 'genre', 'field' => 'slug', 'terms' => 'jazz' ) )
  • 7. How it is done? Most read posts Most commented posts Featured posts Most recent post, second most recent post, etc. from individual categories Plugin: Meta Box Define custom field, ++ on single post views or Plugin: WP-PostViews Most shared on social media posts Plugin: Most Shared Posts Name of meta tag 'meta_key' => '_msp_total_shares' Sort by 'comment_count' or 'date' (default) use 'offset', 'category', 'numberposts' Sort by 'date' (default) with filter 'meta_key' => '_fp', 'meta_value' => '1', Sort by 'meta_value' or 'meta_value_num'
  • 8. Sub-categories listing? Plugin: Categories Images z_taxonomy_image_url(); $args = array( 'type' => 'post', Plugin: Taxonomy TinyMCE (not working?) 'child_of' => 0, Plugin: WP Category Permalink (for SEO) 'parent' => '', 'orderby' => 'name', $categories= get_categories($args); foreach ($categories as $category) : $imgurl = z_taxonomy_image_url( $category->term_id); get_category_link( $category->term_id); echo( $category->slug); echo( $category->cat_name;); endforeach; 'order' => 'ASC', 'hide_empty' => 1, 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'number' => '', 'taxonomy' => 'category', 'pad_counts' => false );
  • 9. Thumbnails Plugin: Categories Images Plugin: Regenerate Thumbnails Plugin: Thumbnail Upscale In functions.php add different sizes for thumbnails: add_image_size(‘n_toprow', 164, 105, true); add_image_size(‘n_mainblog', 300, 260, true); .. In the loop etc. add: the_post_thumbnail( ' n_toprow' ); Bad hack for categories: $imgurl = z_taxonomy_image_url($category->term_id); $imgurlmod = str_replace ( '.jpg' , '-300x260.jpg' , $imgurl );
  • 10. Thank you for your attention! Questions? Roman Rus @RomSocial www.websitesupgrade.com