posts

how do i get only 1 post from each category in wordpress

瘦欲@ 提交于 2019-12-01 05:49:49
i have a category named news and many subcategories inside it. What i wanna do is to get only 1 posts(newest) from each of those sub categories(including category title, post title, attachment image). Is there any suggestions friends?? <?php $news_cat_ID = get_cat_ID( 'News' ); $news_cats = get_categories( "parent=$news_cat_ID" ); $news_query = new WP_Query; foreach ( $news_cats as $news_cat ) : $news_query->query( array( 'cat' => $news_cat->term_id, 'posts_per_page' => 1, 'no_found_rows' => true, 'ignore_sticky_posts' => true, )); ?> <h2><?php echo esc_html( $news_cat->name ) ?></h2> <?php

mysql structure for posts and comments

倖福魔咒の 提交于 2019-12-01 01:44:36
I've read several tutorials, documentations about mysql, db structures and also I'm using it via php for weeks. Now I get a problem, I don't know how to form/organize/create my db structure for posts and comments. I've already read some posts about this (here on stackoverflow), but I didn't find anything useful. I understand that I need to have 2 tables for posts and comments, and when I need to print them on the page with a foreign key (or ID) I "merge" them (only on the page, not with SQL). When a person is viewing the page, he is seeing the post and comments normally, but in the "background

mysql structure for posts and comments

▼魔方 西西 提交于 2019-11-30 20:46:42
问题 I've read several tutorials, documentations about mysql, db structures and also I'm using it via php for weeks. Now I get a problem, I don't know how to form/organize/create my db structure for posts and comments. I've already read some posts about this (here on stackoverflow), but I didn't find anything useful. I understand that I need to have 2 tables for posts and comments, and when I need to print them on the page with a foreign key (or ID) I "merge" them (only on the page, not with SQL).

Facebook page's posts feed

倾然丶 夕夏残阳落幕 提交于 2019-11-30 09:20:50
Does anyone know how to fetch a facebook page's rss-feed nowadays? When I log in as a page and go to http://www.facebook.com/feeds/notifications.php?id=xx&viewer=xx&key=xx&format=rss20 , I get an empty feed. Is there a corresponding "page" feed that contains the pages posts? Thanks, /M The IDs in the URL below are the IDs you need to find to create your rss feed. http://www.new.facebook.com/feeds/notifications.php?id= YOUR_FACEBOOK_ID &viewer= YOUR_FACEBOOK_ID &key= YOUR_INTERNAL_KEY &format=rss20 There are 3 numbers in this URL. The number that follows “id” is your Facebook ID number. This

SQL query to extract all WordPress posts with categories

大兔子大兔子 提交于 2019-11-30 02:24:54
I need to extract all posts from my WordPress DB along with the associated categories and not sure how to write this query. I've taken a couple of stabs at it already with no joy and would appreciate the help? EDIT: Here's what I have tried already: SELECT post_title, wpr.object_id, wp_terms.name FROM wp_terms INNER JOIN wp_term_taxonomy ON wp_terms.term_id = wp_term_taxonomy.term_id INNER JOIN wp_term_relationships wpr ON wpr.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id INNER JOIN wp_posts ON ID = wpr.object_id WHERE taxonomy = 'category' AND post_type = 'post' ORDER by post_title

Facebook page's posts feed

强颜欢笑 提交于 2019-11-29 14:12:52
问题 Does anyone know how to fetch a facebook page's rss-feed nowadays? When I log in as a page and go to http://www.facebook.com/feeds/notifications.php?id=xx&viewer=xx&key=xx&format=rss20, I get an empty feed. Is there a corresponding "page" feed that contains the pages posts? Thanks, /M 回答1: The IDs in the URL below are the IDs you need to find to create your rss feed. http://www.new.facebook.com/feeds/notifications.php?id= YOUR_FACEBOOK_ID &viewer= YOUR_FACEBOOK_ID &key= YOUR_INTERNAL_KEY

How to sort a 'query_posts' function by custom field, while limiting posts by another custom field

柔情痞子 提交于 2019-11-29 08:55:27
I'm querying a series of posts in WP with the following function: <?php $thirtydays = date('Y/m/d', strtotime('+30 days')); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts( array( 'post_type' => array('post', 'real-estate'), 'meta_key' => 'Time Available', 'meta_compare' => '<=', 'meta_value' => $thirtydays, 'paged' => $paged )); ?> This part is working fine. It's basically pulling all my Real Estate posts, but only returning results that have a 'Time Available' of 30 days or less. I need this to also order the posts in ascending order from low to high using the

SQL query to extract all WordPress posts with categories

落爺英雄遲暮 提交于 2019-11-28 23:19:27
问题 I need to extract all posts from my WordPress DB along with the associated categories and not sure how to write this query. I've taken a couple of stabs at it already with no joy and would appreciate the help? EDIT: Here's what I have tried already: SELECT post_title, wpr.object_id, wp_terms.name FROM wp_terms INNER JOIN wp_term_taxonomy ON wp_terms.term_id = wp_term_taxonomy.term_id INNER JOIN wp_term_relationships wpr ON wpr.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id INNER JOIN wp

How to sort a 'query_posts' function by custom field, while limiting posts by another custom field

拥有回忆 提交于 2019-11-28 02:14:16
问题 I'm querying a series of posts in WP with the following function: <?php $thirtydays = date('Y/m/d', strtotime('+30 days')); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts( array( 'post_type' => array('post', 'real-estate'), 'meta_key' => 'Time Available', 'meta_compare' => '<=', 'meta_value' => $thirtydays, 'paged' => $paged )); ?> This part is working fine. It's basically pulling all my Real Estate posts, but only returning results that have a 'Time Available' of

Wordpress Loop posts in Bootstrap 3 grid layout

故事扮演 提交于 2019-11-27 11:44:13
I am using Bootstrap 3 within Wordpess and have an issue getting my archive posts to display across the page in a grid format. My wordpress loop code is... <?php if ( have_posts() ) : ?> <?php $args=array( 'post_type' => 'artist', 'post_status' => 'publish', 'posts_per_page' => -1, 'caller_get_posts'=> 1 ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { echo ''; while ($my_query->have_posts()) : $my_query->the_post(); ?> <li> <img src="<?php the_field('artist_photo'); ?>" alt="" class="img-responsive" /> </li> <?php endwhile; } wp_reset_query(); ?> <?php