What´s the error in this syntax? - html

I'm trying to do something with my Bootstrap .post-title class.
I want to put an element.style background on my post titles, which calls as a background, to the post featured image, for each post. I've already achieve this, but something went wrong and now isnt working. the only thing i know is must look something like this.
<div class="post-featured" style="background-image:url('upload/<?php the_post_thumbnail( 'wpbs-featured' ); ?>')">
but something in the syntax there is wrong, because it render this characters on HTML. whats going on?
')">
live example: WP Featured post image, as a div background

the_post_thumbnail returns an IMG html tag. So the generated code is
<div class="post-featured" style="background-image:url('upload/<img src="path/to/file.png">')">
Definitely not something that could work... You want the url only, so you should do this:
$thumb_id = get_post_thumbnail_id();
$thumb_url = wp_get_attachment_image_src($thumb_id,'wpbs-featured', true);
<div class="post-featured" style="background-image:url('<?= $thumb_url[0] ?>')">

this is the actual html snippet working.
<?php
$img = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "full");
$img = $img[0];
?>
<div class="postfeatured" style="<?php if($img){echo 'background:url('.$img.');';} ?>">
<div class="page-header"><h1 class="single-title" itemprop="headline"><?php the_title(); ?></h1>
<h4>
<?php $mykey_values = get_post_custom_values('_aioseop_description');
foreach ( $mykey_values as $key => $value ) {
echo substr("$value",0 ,300); //This will display the first 150 symbols
}?>
</h4>
<hr>
<!-- Go to www.addthis.com/dashboard to customize your tools -->
<div class="addthis_native_toolbox"></div>
<hr>
</div>
</div>
live example: Design Thinking. Blog de Diseño Gráfico. Picoboero

Related

Wordpress Polylang adding pll_e breaks HTML

i'm using polylang to translate my blog site along with loco translate. i'm manually adding string translations which was working fine with get_theme_mod parts, but there is a place that i want to also add custom string translation, after i add manually it breaks html and css won't work then.
it should be seen like this after adding custom string translation ; works fine without pll_e
but after i add pll_e to the that part in index.html ;
<?php get_header(); ?>
<div class="content">
<?php if ( get_theme_mod('heading-enable','on') == 'on' ) : ?>
<?php echo get_template_part(pll_e ('inc/page-title') ); ?>
<?php endif; ?>
it breaks the html but translation works. its seen like this ; looks like this
does anyone knows the solution ? i think its about get_template_part and get_theme_mod because the same things that i've done with get_theme_mod parts works fine.
by the way there is difference like this with pll_e and without it.
without pll_e
with pll_e
i solved the problem by editing index.html like this ;
<div class="content">
<div class="page-title group">
<div class="page-title-inner group">
<?php if ( get_theme_mod('heading-enable','on') == 'on' ) : ?>
<h2> <?php echo get_template_part(pll_e('inc/page-title') ); ?> </h2>
<?php endif; ?>
</div><!--/.page-title-inner-->

How to make my RSS Feed use more than one image for each news?

Sorry for my really bad english (I also dont know how to build the title very well but I hope it's good enough to understand what I'm trying to do).
I bought this website template, the guy I bought it from has corona and is unavailable right now, that's why I'm asking for help here ^^
This is my homepage https://www.ragnarokeurope.net/
When you open this page, you see my News RSS feed and 4 pictures.
What I'm trying to do is: use a different picture for each of the news.
If you don't want to click the link, here is a picture of what Im talking about
The code for the pictures, I have it here. As you can see, it's made so everything uses the same picture. It would be awesome if somebody could help me change it.
<div id="RO_ACTU_IMG">
<?php
$newslimit = (int)Flux::config('CMSNewsLimit');
require_once('autoloader.php');
$feed = new SimplePie();
$feed->set_feed_url(Flux::config('CMSNewsRSS'));
$feed->enable_cache(false);
$feed->init();
$feed->handle_content_type();
?>
<?php foreach($feed->get_items(0,4) as $rssItem): ?>
<?php
// These News Images are stored in /themes/<theme_name>/img/news/
// In the if-statement, use the name of your News item to dsiplay $newsimage in the feed.
if($rssItem->get_title() == "The League Of Levelers"){$newsimage = "league";}
elseif($rssItem->get_title() == "Halloween Has Landed"){$newsimage = "halloween";}
else{$newsimage = "generic";}
?>
<div class="RO_ACTU_IMG_news">
<img src="<?php echo $this->themePath('img/news/'.$newsimage.'.jpg') ?>" alt="NEWS">
<div class="RO_NEWS">
<h3 class="RO_NEWS_titre"><?php echo $rssItem->get_title() ?></h3>
<p><?php echo date(Flux::config('DateFormat'),strtotime($rssItem->get_date()))?></p>
<p><?php echo substr($rssItem->get_description(),0,170) ?>...</p>
<div class="RO_readmore"><p>Read more</p></div>
</div>
</div>
<?php endforeach; ?>
It looks like that it is possible that get_Title() is not eval'ing to your text. None of the titles in the image match the text you are comparing as well.

Magento: remove <p> tags from the header logo image - "Need file path"

What I'm attempting to do is to remove some <p> tags that wrap the header logo image which does not contain any text because I think they should not be there.
But this is throwing the following error when testing via the W3-validator.
Line 261, Column 216: Element p not allowed as child of element a in
this context. (Suppressing further errors from this subtree.)
What file should I look in to locate line 261?
I'm stuck. I've searched for hours and can't find the file-path to the file that contains the string I need to edit. I currently don't have access to link hints function so that out of the question.
Any suggestions would be highly appreciated.
Thanks a million
Fish
Update: Here is some code regarding the logo from the header.phtml
<div class="header-wrapper <?php echo $hdr_style?>">
<header>
<?php if ( $config['design']['below_logo'] ) : ?>
<div class="row clearfix">
<div class="grid_12">
<?php if ($this->getIsHomePage()):?>
<h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><?php echo $this->getChildHtml('theme_logo', false) ?></h1>
<?php else:?>
<strong><?php echo $this->getLogoAlt() ?></strong><?php echo $this->getChildHtml('theme_logo', false) ?>
<?php endif?>
The code comes from <?php echo $this->getChildHtml('theme_logo', false) ?>.
You need to check the layout files in the theme and see which template the 'theme_logo block' is using. That's where you can find and remove the <p> tags.

Wrong post title displaying from wordpress loop

I'm building my own theme. I have a page set for my blog (with a template that I made) which I'd like to just display a few of my posts. It uses the following loop:
<?php
query_posts('post_type=post');
if (have_posts()) {
while (have_posts()) {
?>
<div class="blog_post">
<h2><?php the_title(); ?></h2>
<div class="entry_date"><?php the_time('F jS, Y') ?></div>
<?php
the_post();
the_content();
?>
</div>
<?php
}
}
?>
The titles of my posts are "First Post, Second Post, Third Post, and Fourth Post" respectively. When the posts are displayed on the blog page, they are displayed in the correct order, but the titles of the posts are incorrect. The first post's title reads: "Second Post". The second post's title is: "Third Post", and so on until the last (most recent) post which has the title: "Blog" (the page title). What happened to the titles that they got so screwed up?
What I've Tried:
I've researched this a lot before I came here. I tried using get_the_title() instead but that lead to no titles being displayed. I've also tried using the_title_attribute() to no avail. I also understand that I shouldn't be using query_posts for this loop but I'm unsure which is the correct method to use for getting the posts in this particular case. Most of the info I've read was unclear though and didn't seem to fix the issue.
Any help is greatly appreciated.
Try something like this: untested
<?php
global $post;
$args = array();
$myposts = get_posts( $args );
foreach( $myposts as $post ) :
setup_postdata($post); ?>
YOUR HTML HERE
<?php endforeach;
wp_reset_postdata(); ?>
Okay Nevermind! I just found out what the problem was. I moved, "the_post()" to just after the while loop so now it reads like this:
<?php
query_posts('post_type=post');
if (have_posts()) {
while (have_posts()) {
the_post();
?>
<div class="blog_post">
<h2><?php the_title(); ?></h2>
<div class="entry_date"><?php the_time('F jS, Y') ?></div>
<?php
the_content();
?>
</div>
<?php
}
}
?>
I found this solution while I was reading about the_post() in the wordpress codex. Turns out this function is setting up information for the next post in the line, so it shouldn't be mixed in with the html output for the current post.
In regards to whether or not I should be using "query_posts()" is still something I'm unsure of and willing to take any advice. But the loop in it's current form is working.

switching between regular html and jQuery mobile site acting strange [duplicate]

I have a wordpress site, that need to show pages using swipe, I choose to use Jquery Mobile, and I get it working fine. Now, we have 2 languages on site, using wpml plugin. And my Swipe Code works well, except when we use Change language button swipe fails.
Details on issue.
We have only 3 Text Only page in our website, in 2 language. And in Footer we have link to change language. Also client hate to have Ajax page loading, so what I did is I create three Div with data-role=page and put data-next, data-prev as #div-$postid. So the navigation works absolute fine. I put footer outside from data-role=page.
Now, when I click change button in footer, it load the english page [I saw it using Fiddler] and then take first data-role=page from server and replace /slide its content. However since it only pick the first data role, all other english page doesn't get in HTML [it just update DOM and doesn't navigate to english version]. so swipe fails as other english pages are not in dom.
Also, footer is not changing, so what I want is: can we simple force a Link to navigate instead of going swipe way? Jquery Mobile is enforcing swipe on all A tags, I do not want swipe to works anything outside data-role=page.
Hope I make sense.
Edit here is code: [not sure if this code will help at all]
<?php
get_header();
global $post;
$args = array('post_type' => 'mobile_slide','showposts' => '-1', "order" => "DESC");
$the_query = new WP_Query($args);
if($the_query->have_posts()){
while($the_query->have_posts()) { $the_query->the_post();
$prev =get_previous_post();
$next =get_next_post();
if($prev) {
$prev = "#page-" . $prev->ID; //get_permalink($prev->ID);
} else {
$prev='';
}
if($next) {
$next = "#page-".$next->ID; //get_permalink($next->ID);
} else {
$next='';
}
if (has_post_thumbnail( $post->ID ) ) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'slider_image' ); ?>
<div id="page-<?php echo $post->ID; ?>" data-dom-cache="true" data-transition="slide" class="page" data-role="page" data-prev="<?php echo $prev; ?>" data-next="<?php echo $next; ?>" style="background-image:url('<?php echo $image[0]; ?>'); background-position:center center; background-color:#000; background-repeat:no-repeat; ">
<?php } else { ?>
<div id="page-<?php echo $post->ID; ?>" data-dom-cache="true" data-transition="slide" class="page" data-role="page" data-prev="<?php echo $prev; ?>" data-next="<?php echo $next; ?>">
<?php } ?>
<div class="post_box">
<h2><blockquote><?php the_title(); ?></blockquote></h2>
<div class="post_entry">
<?php the_content(); ?>
</div>
</div><!-- post_box -->
</div>
<?php }
} ?>
<?php get_footer(); ?>
This is all I have, except that get_footer use Ul li based list where on LI change based on language variable, to show different images for either language.
To stop Ajax from loading pages/links, add to link anchor data-rel="external" or data-ajax="false". This will load page normally without any transition.
Reference: jQuery Mobile - Links
For those who have similar problem, I fix it by using following:
1) I add a "noswipe" class to A Tag so I can refer it in Jquery
2) I add following code
$(function(){
$(".noswipe").click(function(){
window.location.href= $(this).attr("href");
return false;
});
});
The above code simply enforce to skip the Mobile's parsing and calling and works for my case.