I am new to web page development. Something I would like to do, is create a link to a sub-page, and have the text part of the link display the meta description of the sub-page dynamically. So if at some point I update the description of the sub page, then refresh the browser on the main page, that updated description will display automatically in the link. Any idea how to do that?
You will need php for this. Something like
<?php
$tags = get_meta_tags('http://www.yousite.com/');
$content = $tags['description'];
echo "".$content."";
?>
Related
Specifically I would like the home link to return them to a landing page if they first landed on that landing page. So lets say they land on a city landing page, then they visit other pages on the site I would like if they hit the home page link on those pages to be sent back to the city landing page. Is this possible? If so please explain.
I don´t really understand what you want but you can create logics in php. Use sessions to save wether or not a user visited the site. If you want more information or a better answer write names for the pages and write exactly what the client does and what changes html should have
Edit
It´s not possible in html. You set a php session (for example $_SESSION['site']) to the URL of the site you want the user to return to. You got to use a server and php so you have to save a.html as a.php. Download for example xampp and put your files into the htdocs folder. Start the Apache server.
Lets say you have the follownig:
htdocs/
|- index.php
|- a.php
|- b.php
Add this to the beginning of index.php. This will return the user to the site you put into $_SESSION['site']:
<?php
session_start();
if (isset($_SESSION['site'])) {
header('Location: '.$_SESSION['site']);
exit();
}
?>
This is how you set the session. For example in page b.php:
<?php
session_start();
$_SESSION['site'] = '/b.php';
?>
or in a.php
<?php
session_start();
$_SESSION['site'] = '/a.php';
?>
If you want to delete the session you can for example make a site (htdocs/stop-session.php) with this code:
<?php
session_start();
session_destroy();
header('Location: /');
exit();
?>
Another way is JS but thats far more complicated in my eyes. You could use coockies there.
I hope it helps. If you want any changes comment
On my wordpress site on the sidebar I have a text widget. I want do display the blogname (blogtitle) there. I want an HTML code, that crab and show the blogtitle by itself. I tried with this code but nothing happened:
<?php bloginfo('name'); ?>
I searched on Google but didn't find anything useful.
Can someone help me please?
When given the 'name' as parameter Wordpress looks for “Site Title” set in Settings > General. Check if this is set.
I have been asked to tweak a friend's website. The website was built for them using Wordpress by an agency they no longer work with. Problem is, I don't know very much about Wordpress, so I have some basic questions…
I can see (by comparing the source as viewed in my browser to the php templates that I can edit through the Wordpress interface) that the elements I need to modify are generated by the page's call to "the_content()". I don't really understand what this function does, but I think it pulls content for a given page from the MySQL database. Is that right?
I suspect that the Wordpress interface alone won't be enough to let me modify elements that come out of that database. Is that correct? How does anyone change, for example, the specific arrangement of text and images on a page if the relevant markup is fetched by "get_content()"?
When developing for WordPress or even just tweaking, it's really important to get at least a general understanding of the "loop" and how we use it for output. In order to output the content you need to call the method within the loop. If it's not within the loop it won't get inserted into your page.
(It works this way with all of your pages... index.php, page.php, single.php, post.php, etc... Your methods need to be placed within the loop in order for them to display within that page.)
Here's a simple example of the way the loop is used to output the title and content of posts:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> // loop start
<h1><?php the_title() ;?></h1>
<?php the_content(); ?>
<?php endwhile; else: ?> // loop end
<p>Sorry, this page does not exist</p>
<?php endif; ?>
If you take a look at any standard WordPress theme (take Twenty Fourteen, for example), you'll find that the_content() is output together with calls to other elements (in this case - the_title()). If you want to want to change the arrangement of the specific elements within your page, just modify the order as they are within your loop, or check the WordPress Codex for additional options/methods.
Here's a short list of some other things you can display:
next_post_link – Displays a link to the post published chronologically after the current post.
previous_post_link – Displays a link to the post published chronologically before the
current post.
the_category – Displays the category or categories associated to the post or page being viewed.
the_author – Displays the author of the post or page.
the_content – Displays the main content for a post or page.
the_excerpt – Displays the first 55 words of a post’s main content then with a [...] or read more link that goes to the full post. The length of excerpts can be controlled by using this slightly advanced method or by using the Excerpt field on the post edit page.
the_ID – Displays the ID for the post or page.
the_meta – Used to display custom fields.
the_shortlink – Displays a link to the page or post using the url of the site using
the ID of the post or page.
the_tags – Displays the tag or tags associated with the post.
the_title – Displays the title of the post or page.
the_time – Displays the time or date for the post or page. This can be customized using the standard php date function formatting.
If you want to further customize some of these methods, you can do that within functions.php. Otherwise, all styling is done within your styles.css.
Probably your content is being generated by a shortcode.
You can modify the content that wordpress fetches from the database with the_content filter:
// returns the content of $GLOBALS['post']
// if the page is called 'debug'
function my_the_content_filter($content) {
// assuming you have created a page/post entitled 'debug'
if ($GLOBALS['post']->post_name == 'debug') {
return var_export($GLOBALS['post'], TRUE );
}
// otherwise returns the database content
return $content;
}
add_filter( 'the_content', 'my_the_content_filter' );
maybe its not the best solution but you can modify the content before it gets output.
source
I am not familiar with PHP Syntax. Now i added JSON Plugin to my wordpress website and activate it.
When i open url to get_recent_post , it's fine. JSON data are showing.
But when i open get_post , it's only showing
{"status":"error","error":"Include 'id' or 'slug' var in your request."}
So i don't know how to add post id to that URL.
here is the pic. Another get_page , gate_date_posts, etc... links are same showing error.
How can i do it?
To display a post's ID, simply use the following PHP code within the WordPress loop:
<?php the_ID(); ?>
To return the ID, use the following PHP code within the WordPress loop:
<?php get_the_ID; ?>
To get a post's id outside of the WordPress loop use the following PHP code:
<?php global $post; $post->ID ?>
Hope that helps you.
http://yoursite.com/api/get_posts/
with the s
If you use the WordPress link and click on it, you will be fine.
I'd like my web page to have a "Show Source" link that will show the source of my HTML.
I'm also wondering if there's something I could append to the URL of my page that'll just show the source as opposed to rendering the page. Like this...
http://www.example.com/mypage.html#show_source
If you are okay with a link that opens source, you could use the following javascript:
if you are using FF:
window.location = "view-source:" + window.location.href;
and with IE:
var popup=window.open();
popup.document.open('text/plain').write(document.documentElement.outerHTML)
If all you need is code between the body tags - then you could do the following:
document.body.innerHTML
Can you provide a bit more information on the application?
"View Source Button" could be a solution, but if you need a direct link you need to change the Content-Type Header of your file to "plain/text".
If your page could be, for example, a PHP script, it would be:
<?php if($_GET["viewsource"]=="yes") header("Content-Type: plain/text"); ?>
and you can open link by appending ?viewsource=yes to your URL.
Remember, it works only "server side".