Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I am trying to display a blog: http://miletich2.blogspot.co.uk/ on my clients Wordpress site and as I have been looking around people have been recommending simple pie and their demo works great, but their Wordpress plugin hasn't been updated in 2 years and has loads of bugs.
Does any one know of another plugin that has the same functionality? Any help would be appreciated!
You can use fetch_feed function.
E.g. to show 5 posts with the provided blog:
<?php
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed('http://miletich2.blogspot.com/feeds/posts/default?alt=rss');
$maxitems = 0;
if (!is_wp_error($rss)) { // Checks that the object is created correctly
// Figure out how many total items there are, but limit it to 5.
$maxitems = $rss->get_item_quantity(5);
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);
}
?>
<ul>
<?php if ($maxitems == 0) : ?>
<li><?php _e('No posts found', 'text-domain'); ?></li>
<?php else : foreach ($rss_items as $item) : ?>
<li>
<a href="<?php echo esc_url($item->get_permalink()); ?>">
<?php echo esc_html($item->get_title()); ?>
</a>
<span>(<?php echo $item->get_date(get_option('date_format')); ?>)</span>
</li>
<?php endforeach; endif; ?>
</ul>
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
so i have got this string:
<?php
$elements = "first, second, third, fourth, fifth";
?>
And i'd like it to be echoed out like this:
<ul>
<li>first</li>
<li>second</li>
<li>third</li>
<li>fourth</li>
<li>fifth</li>
</ul>
Try this, it may help you issue;
<?php
$elements = "first, second, third, fourth, fifth";
$numbers = explode(", ", $elements);
echo "<ul>";
foreach ($numbers as $number) {
echo "<li>{$number}</li>";
}
echo "</ul>";
?>
$elements = "first, second, third, fourth, fifth";
$arrayval=explode(',',$elements);
print_r($array);?>
<ul><?php
foreach($arrayval as $value){ ?>
<li><?php echo $value; ?></li>
<?php } ?>
</ul>
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I created this code for a dropdown navigation menu. I have 2 tables in my database, one for parentitems and the other one for childitems. The parents getting out correctly, but the childitems won't.
The problem is, I only get one parent and one child at a time, or I get totally nothing.
Thanks in advance!
My code:
<?php
$con=mysql_connect("localhost","root","");
$db=mysql_select_db('navigation',$con);
$query="select * from nav";
$run=mysql_query($query);
while($row=mysql_fetch_array($run)){
$m_id=$row['m_id'];
$m_title=$row['m_title'];
$child_query="select * from nav_child where parent_id='$m_id'";
$run_child=mysql_query($child_query);
while($row_child=mysql_fetch_array($run_child)) {
$child_id=$row_child['nav_id'];
$child_title=$row_child['child_title'];
echo"<ul>
<li><a href='menu.php'>$m_title</a>
<ul>
<li><a href='menu.php'>$child_title</a></li>
</ul>
</li>
</ul>";
}
}
?>
You need to split your html
while(mainquery) {
echo '<ul>' <-----note the location
while (subquery) {
echo '<li>subquery 1 stuff</li>'
}
echo '</ul>' <-----note the location
}
You're outputting it entirely in your subquery section, so EVERY child row gets its own complete <ul><li>...</li></ul> tag set.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Hello I would like to set li active in PHP: if it's clickable, then it's active, if not then it's not active. I've tried several ways but nothing works. Here's my code :
<ul>
<?php
$sql = mysql_query("SELECT * FROM pages WHERE isRoot='1' ORDER BY pageID");
while ($row = mysql_fetch_object($sql))
{
echo "<li>$row->pageTitle </li>";
}
?>
</ul>
The easiest way is to us a GET parameter.
The link to your site than will be index.php?pageID=11 - in this case 11 stands for die pageID 11
in your while loop you have to check if this site is the active one
if($row->pageID == $_GET['pageID'])
{
//active li
echo "<li class="active">$row->pageTitle </li>";
}
else
{
//normal li
echo "<li>$row->pageTitle </li>";
}
You could do the same with PageTitle too
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a search bar and a sql database with 3 movies in
Name:Star Wars: Description: Contains the word group
Name:301: Description: Contains the word group
Name:destroyer: Description: Contains the word group
BUT when ever I search for the word "group"
I only get one result usually:
if i search for group star wars will appear 3 time.
also i know its vulnerable to sql injection but at the moment that is not an issue
here is my php code:
if(!isset($_POST['search']))
{
header("Location:index.php");
}
$search_sql="SELECT * FROM php_item WHERE Name LIKE '%".$_POST['search']."%' OR Description LIKE '%".$_POST['search']."%'";
$search_query = mysql_query($search_sql);
if(mysql_num_rows($search_query)!=0)
{
$search_rs= mysql_fetch_assoc($search_query);
}
?>
</p>
<p> Search Results</p>
<?php
if(mysql_num_rows($search_query) != 0){
do{ ?>
<p>
<?php echo $search_rs['Name']; ?>
<?php }while($searchr_rs=mysql_fetch_assoc($search_query));
} else {
echo "No Results Found";
}
?>
If this is your code, there is a typo in the while. It should be $search_rs=mysql_fetch_assoc($search_query). You have an extra 'r'.
Good Luck!
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am new to wordpress , I need to know how to find the category id instead of category name ?
in the wordpress .
Any one Much appreciated
Reg,
vicky
<?php
$category_id = get_cat_ID('Category Name');
$q = 'cat=' . $category_id;
query_posts($q);
if (have_posts()) : while (have_posts()) : the_post();
the_content();
endwhile; endif;
?>
Taken from the Wordpress Codex: http://codex.wordpress.org/Function_Reference/get_cat_ID
Did you try?
global $wp_query;
$cat_ID = get_query_var('cat');