PHP - Php And Wordpress Template
How do I incorporate wordpress php usage withing standard php? For example, this is typically the template used for the title in wordpress:
Code: [Select] <?php the_title(); ?> How would I show that in php, like: Code: [Select] $title = the_title(); //this doesn't work by the way Similar TutorialsHey guys, I am new here to this forum as well as web development.
I have created my first website which is pier36nyc.com
My only problem so far is trying to make the events page dynamic.
http://pier36nyc.com/events/
If you take a look at the events page, there is a gallery of pictures which display a title, caption, an image, and a button link when you hover above it.
The problem is, all of that is static for now. The code for that is on my 'Pages' section where I just HTML everything in there. I also used JQuery for the hover effect.
How do I make this gallery dynamic so that when a user wants to create a block, there will be a tool (which I think I will have to create through PHP, which I need help from you guys) that allows the user to input the desired Title, Caption, Image, and Link to that block.
The problem is: I have very minimal knowledge in PhP. I'm interning right now and learning everything all at once. I'm losing my mind right now >_<
I know it's not as complicated as I try to make it sound. But I'm just stressed out
Can someone please help me out?
I would greatly appreciate it..
Edited by mac_gyver, 22 October 2014 - 11:55 AM. fixed title Good morning
I'm trying to add a widget to a WordPress template using PHP. It works, but the problem is that the widget ends up on a new line in the header instead of next to the logo as I want it. The code looks like this:
<div class="branding_wrap"> <?php pagelines_main_logo(); ?> <?php pagelines_register_hook( 'pagelines_before_branding_icons', 'branding' ); // Hook ?> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('header-1') ) : ?> <?php endif; ?>I've attached a screenshot of the current header to this post. Can anyone tell me what I'm doing wrong? I'm pretty new at PHP. Thank you! Attached Files blogheader.png 24.48KB 0 downloads Hey guys,
Wordpress has the ability to recognize a custom page and make it available to select it and use when you are logged in in the pages section of the admin ui. To make it work you add this:
<?php /* * Template Name: My Custom Page * Description: A Page Template with a darker design. */ // Code to display Page goes here...My question is how does wordpress scan and find these files and then show them in a drop down menu on the pages tab of the admin? Is it done with regular expressions? Many thanks for any help! This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=358619.0 I have a php tutorial that I followed for creating, inserting, selecting and updating a MySQL database with php. Everything works fine so I wanted to put it into Wordpress. I took the code and placed it into the wordpress page and everything worked just fine except the update function. Here is the tutorial I used. http://www.phpsimple.net/mysql_insert_record.html It is also the part I am having trouble with. I am able to create a record and I am also able to select a record but when I choose "update" the form doesn't load the data. It will outside the website but not inside wordpress. I am hoping this is not vague but because of my inexperience I am not sure what else to say. I will be more than happy to provide any other information you need. I've been trying to use an example I got off of this forum. The PHP file works fine as a separate PHP file. When it's adding into a wp page the following results occur; Page will access db and display the list of people. Columns can be sorted by either the id or name. Existing names can be modified However; Can not add new players or delete players ANY suggestions are appreciated! <?php /**** Dealing with the database ****/ // connect to db $conn = mysql_connect('xxxxxxxxxx','yyyyyyyyyy','zzzzzzzzzzzzz') or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('ddddddddddddd',$conn) or trigger_error("SQL", E_USER_ERROR); // INSERT: if we have a name to add... if($_GET['name']) { // little bit of cleaning... $name = mysql_real_escape_string($_GET['name']); // insert new name into table $sql = "INSERT INTO info (id, name) VALUES ('','$name')"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); } // end if // UPDATE: if we have name(s) to change... if($_POST['cname']) { // for each name to change... foreach($_POST['cname'] as $cid => $cname) { // little bit of cleaning... $id = mysql_real_escape_string($cid); $name = mysql_real_escape_string($cname); // update name in the table $sql = "UPDATE info SET name = '$name' WHERE id = '$id'"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); } // end foreach } // end if // DELETE: if we have a name to delete... if($_GET['name']) { // little bit of cleaning... $name = mysql_real_escape_string($_GET['name']); // delete name from table $sql = "DELETE FROM info WHERE name = '$name'"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); } // end if // ORDERBY: if one of the links was clicked.. if ($_GET['orderby']) { // make an aray of allowed names $allowed = array('id','name'); // bit of cleaning... $order = mysql_real_escape_string($_GET['orderby']); // is it a valid column name? yes: use it. no: default to 'id' $order = (in_array($order, $allowed))? $order : "id"; // if no link clicked, default to 'id' } else { $order = "id"; } // end else // SELECT: get the list of names from database $sql = "SELECT id, name FROM info ORDER BY $order"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); /**** end deal with the database ****/ /**** list everything out ****/ // list columns echo <<<LISTCOLS <form action = '{$_SERVER['REQUEST_URI']}' method = 'post'> <table border = '1'> <tr> <td><a href = '{$_SERVER['REQUEST_URI']}?orderby=id'>id</td> <td><a href = '{$_SERVER['REQUEST_URI']}?orderby=name'>name</td> <td>delete</td> </tr> LISTCOLS; // loop through list of names while ($list = mysql_fetch_assoc($result)) { echo <<<LISTINFO <tr> <td>{$list['id']}</td> <td><input type = 'text' name = 'cname[{$list['id']}]' value = '{$list['name']}'> <td><a href = '{$_SERVER['REQUEST_URI']}?name={$list['name']}'>delete</a></td> </tr> LISTINFO; } // end while // list input box for adding new entry echo <<<NEWENTRY <tr> <td bgcolor = 'gray'></td> <td><input type = 'text' name = 'name'></td> <td bgcolor = 'gray'></td> </tr><tr> <td></td> <td align = 'center'><input type = 'submit' value = 'submit'></td> <td></td> </tr> </table> </form> NEWENTRY; /**** end list everything out ****/ ?> I am new here I dont know if I am breaching any policy by posting questions.
Are there any Tutorials that can give me input for wordpress basics such as listed here -
http://codex.wordpress.org/Plugin_API
http://codex.wordpre...Class_Reference
I would be indebted if you can help me with that.
Looking Forward. Cheers!
hey guys im making a template class which is working and im trying to impliment a loop section for MySQL results... but i need to be able to find a match for a string such as: {section name=1 loop=$2} content {/section} but also extract the values of name, loop and the section content if anyone could advise me on the best way this can be done please...thank you Hello nice php experts :-) I've just changed the theme on my wordpress page but wish to add a couple of links to my non-wordpress pages to it. This is the line of code where I wish to add some more links. I'm going to use the page-link class to format the links but I'm not sure where I would add the extra divs in amongst all of those commas and brackets. <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', '' ), 'after' => '</div>' ) ); ?> Any help is gratefully accepted. I placed car-dealer-website, a web application from car-dealer-website.org , in a subdirectory on my host mysite.com/car. Wordpress is public_html (mysite.com). What I am trying to do is embed mysite.com/car in Wordpress. I tried iframe and it is ugly. I looked for a php css options,using a code I found online, it didnt work but I saw hope and think php and css is the solution. What I am asking for is direction on using php and css to embed in Wordpress. I want to write code no plugins. I hope to learn some php coding. Thank you in advance for your suggestions, tutorials, different methods. This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=310048.0 What I remember from my college days is that isset check whether the variable has a value set or not and return true or false value.
However I encountered a code in wordpress -
// Set up the content width value based on the theme's design and stylesheet. Hi
I need to add one more function in my wordpress plugin. below is the sample code working for 2nd tier. Now i need a same function for 3rd and 4th tire.
Function explanation
I am A and i refer B and if B made any sale means I (A) will get direct commission for that sale.
If B refer C and if C made any sale means (B) will get direct commission for that sale. And in this sample code me(A) also get commission for that sale as a 2nd tier.
Now C refer D and if D made any sale means © will get direct commission for that sale and (B) will get 2nd tier commission. So here (A) me too should get 3rd tire commission and i need that function.
Please help me.
function wp_aff_award_second_tier_commission($wp_aff_affiliates_db,$sale_amount,$txn_id,$item_id,$buyer_email,$buyer_name='') { global $aff_tx_msg; $clientdate = (date ("Y-m-d")); $clienttime = (date ("H:i:s")); if (get_option('wp_aff_use_2tier') && !empty($wp_aff_affiliates_db->referrer)) { $aff_tx_msg .= '<br />Using tier model'; wp_affiliate_log_debug("Using tier model",true); $award_tier_commission = true; $duration = get_option('wp_aff_2nd_tier_duration'); if(!empty($duration)) { $join_date = $wp_aff_affiliates_db->date; $days_since_joined = round((strtotime(date("Y-m-d")) - strtotime($join_date) ) / (60 * 60 * 24)); if ($days_since_joined > $duration) { $aff_tx_msg .= '<br />Tier commission award duration expried'; wp_affiliate_log_debug("Tier commission award duration expried! No tier commission will be awarded for this sale.",true); $award_tier_commission = false; } } if ($award_tier_commission) { if(!empty($wp_aff_affiliates_db->sec_tier_commissionlevel)){ $second_tier_commission_level = $wp_aff_affiliates_db->sec_tier_commissionlevel; wp_affiliate_log_debug("Using the affiliate specific 2nd tier commission for this referral. 2nd tier commission level: ".$second_tier_commission_level,true); } else{ $second_tier_commission_level = get_option('wp_aff_2nd_tier_commission_level'); wp_affiliate_log_debug("Using global 2nd tier commission for this referral. 2nd tier commission level: ".$second_tier_commission_level,true); } if (get_option('wp_aff_use_fixed_commission')) { $commission_amount = $second_tier_commission_level; } else { $commission_amount = round(($second_tier_commission_level * $sale_amount)/100,2); } $campaign_id = ""; $is_tier_comm = "yes"; global $wpdb; $aff_sales_table = WP_AFF_SALES_TBL_NAME; $updatedb = "INSERT INTO $aff_sales_table (refid,date,time,browser,ipaddress,payment,sale_amount,txn_id,item_id,buyer_email,campaign_id,buyer_name,is_tier_comm) VALUES ('$wp_aff_affiliates_db->referrer','$clientdate','$clienttime','','','$commission_amount','$sale_amount','$txn_id','$item_id','$buyer_email','$campaign_id','$buyer_name','$is_tier_comm')"; $results = $wpdb->query($updatedb); $aff_tx_msg .= '<br />Tier commission awarded to: '.$wp_aff_affiliates_db->referrer.'. Commission amount: '.$commission_amount; wp_affiliate_log_debug('Tier commission awarded to: '.$wp_aff_affiliates_db->referrer.'. Commission amount: '.$commission_amount,true); } } return $aff_tx_msg; } How to work with frameworks ??? from where whould I start learning this topics ??
Greetings all,
Been trying to make a plugin in wordpress and ran into an issue with the way wordpress makes use of ajax in the administration menu. The problem is that I completely don't understand it. I've read all the docs on it and even tried messing with a variety of tutorials on the matter to no avail.
What I am trying to do is a simple task outside of wordpress. The form has two select fields, the first field populates the second selection field. While this works fine on a standard html page, trying to do it in wordpress is another story.
Form.php:
<div id="wrapper"> <h1>Second dropdown selection based </h1> <form action="" method="post"> <p><label>Main Menu :</label> <select name="main_menu_id" id="main_menu_id"> <option value="">Select</option> <?php // Connect to database. $connect = mysqli_connect('<!--DB connection info-->"); $q = mysqli_query($connect, "SELECT cfid,cfname FROM categoryfiles ORDER BY cfid"); while($row = mysqli_fetch_array($q)) { echo '<option value="' . $row['cfname'] . '">' . $row['cfname'] . '</option>'; } ?> </select> </p> <p><label>Sub Menu: </label> <select name="sub_menu_id" id="sub_menu_id"></select> </p> </form> </div>The script.js $(function() { $("#main_menu_id").bind("change", function() { $.ajax({ type: "GET", url: "scripts/get_sub_category.php", data: "main_menu_id="+$("#main_menu_id").val(), success: function(html) { $("#sub_menu_id").html(html); } }); }); });The get_sub_category.php <?php // Connect to database. $connect = mysqli_connect('<!--My connection info-->); $id = $_GET['main_menu_id']; $q = mysqli_query($connect, "SELECT sfid, sfname FROM subjectfiles WHERE sfcategory='" . $id . "' ORDER BY sfname"); while($row = mysqli_fetch_array($q)) { echo '<option value="' . $row['sfname'] . '">' . $row['sfname'] . '</option>'; } ?>Like I said, it works just fine outside of wordpress so really I just need help getting it to work in wordpress. I just don't understand it. Thanks to anyone that takes the time to look this over. Best Regards, Nightasy Hi all, I have the following which displays my posts on a wordpress blog <?php $x = 0; while (have_posts()) : the_post(); update_post_caches($posts); $x++; ?> <li<?php if ($x % 2) { } else { echo ' class="right_col"';} ?>> <?php unset($img); if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail() ) { $thumbURL = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), '' ); $img = $thumbURL[0]; } else { unset($img); if ($wpzoom_cf_use == 'Yes') { $img = get_post_meta($post->ID, $wpzoom_cf_photo, true); } else { if (!$img) { $img = catch_that_image($post->ID); } } } if ($img) { $img = wpzoom_wpmu($img); ?> <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo $img ?>&w=75&h=75&zc=1" alt="<?php the_title(); ?>" /></a><?php } ?> <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a><span class="comm_bubble"><?php comments_popup_link('0', '1', '%', ' ', ' '); ?></span> <span class="meta"><?php the_time("$dateformat $timeformat"); ?> <?php edit_post_link( __('Edit', 'wpzoom'), ' ', ''); ?></span> <?php wpe_excerpt('excerpt_tabs', 'wpe_excerptmore'); ?> </li><?php endwhile; ?> </ul><?php endif; ?> What I would like to do is limit the max posts to 6, but I cant seem to work out a way of doing it! Any pointers? Cheers Hi Everybody.
Apologies if I've not posted this in the correct forum, but the following line of WordPress code displays the ‘Title’ of my individual blog posts in the Sidebar.
<a href="<?php the_permalink(); ?>"><?php get_the_title() ? the_title() : the_ID(); ?></a>
Can somebody please help me tweak it so it displays both the ‘Title’ and ‘Subtitle’ of each post please? So far I’ve tried adding the ‘Subtitle’ at the end, like this:
<a href="<?php the_permalink(); ?>"><?php get_the_title() ? the_title() : the_ID(); ?><span class="subtitle"><?php the_subtitle(); ?></span></a>
This works in the sense that both the ‘Title’ and ‘Subtitle’ are displayed (both of which are styled in slightly different colours using a separate CSS file), but while the ‘Title’ changes font colour on mouse-hover, the ‘Subtitle’ doesn’t (I’m guessing because I’ve wrapped it in a span class). What I’m really hoping to do is have the ‘Title’ displayed in one colour and the ‘Subtitle’ in a slightly different colour, but for both ‘Title’ and ‘Subtitle’ to change to the same colour when the mouse hovers over either one of them. I’m still building my site, but you can see the Sidebar as it stands, here http://www.retelevise.com.
I don’t know if this is even possible and have not had any feedback on the WordPress support forum, so was really hoping one of the PHP experts here might be able to help me please? Bear in mind I'm a complete PHP novice.
Thanks,
SN.
Hi, I m creating a website (Wordpress) for my client. I need a small help. Hi - I'm using the WP Job Boards plugin for Wordpress. I've been given this code to create a quick search form to place in a widget. I've tried to paste the code in a sidebar widget and apparently after somebody inputs the keyword and location they should be sent to the results page which will show their results, however, it's not doing that, just showing me a 'page cannot be found' result.
Can anybody help me out with correcting the code?
<form action="<?php esc_attr_e(wpjb_link_to("http://www.littlefox...k/etsgroup/jobs")) ?>" method="GET"> Hi:
I have a wordpress, and I want to publish a flash animation.
I´ve modified the wordpress file sidebar.php with a include to this code in another .php file, but I don´t see nothing, but I don´t have any error... just "white space" instead the animation...
Can you help me with the code??
<? $wmode = "opaque"; $refererId = 258; $bannerId = 210; $width = 250; $height = 250; $link = "http://www.bellross.com/index.php?bannerId=".$bannerId."&refererId=".$refererId; $flashLink = "http://www.bellross.com/index.php?bannerId=".$bannerId."%26refererId=".$refererId; ?> <style type="text/css"> body, object { padding:0; margin:0; } #timekeeper, .link { width: <?= $width?>px; height:<?= $height?>px; } .hand { bottom: 0px; left: 107px; } </style> <link href="wp-content/themes/sahifa/template/style.css" rel="stylesheet" type="text/css"/> <script type="text/javascript"> window.onload = function() { if(document.getElementsByTagName('body')[0].style.MozTransform == '' || document.getElementsByTagName('body')[0].style.WebkitTransform == '' || document.getElementsByTagName('body')[0].style.OTransform == '' || document.getElementsByTagName('body')[0].style.transform == '') { function hand() { handS.style.MozTransform = handS.style.WebkitTransform = handS.style.OTransform = handS.style.transform = 'rotate(' + (time * 6) + 'deg)'; handM.style.MozTransform = handM.style.WebkitTransform = handM.style.OTransform = handM.style.transform = 'rotate(' + (time / 10) + 'deg)'; handH.style.MozTransform = handH.style.WebkitTransform = handH.style.OTransform = handH.style.transform = 'rotate(' + (time / 120) + 'deg)'; } var handH = document.getElementById('handH'); var handM = document.getElementById('handM'); var handS = document.getElementById('handS'); var timekeeper = document.getElementById('timekeeper'); var d = new Date(); var time = d.getSeconds() + 60 * d.getMinutes() + 3600 * d.getHours(); hand(); setInterval(function() {time = time+0.20; hand();}, 200); setInterval(function() {r = new Date(); time = r.getSeconds() + 60 * r.getMinutes() + 3600 * r.getHours(); hand()}, 10000); } }; </script> <script src="wp-content/themes/sahifa/swf/Scripts/swfobject_modified.js" type="text/javascript"></script> <script type="text/javascript"> swfobject.registerObject("FlashID"); </script> <object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="<?= $width?>" height="<?= $height?>"> <param name="movie" value="wp-content/themes/sahifa/swf/timekeeper.swf"> <param name="quality" value="high"> <param name="wmode" value="<?= $wmode?>"> <param name="swfversion" value="8.0.35.0"> <param name="FlashVars" value="clickTAG=<?=$flashLink?>" /> <!-- Cette balise <param> invite les utilisateurs de Flash Player en version 6.0 r65 et ultérieure à télécharger la version la plus récente de Flash Player. Supprimez-la si vous ne voulez pas que cette invite soit visible. --> <param name="expressinstall" value="wp-content/themes/sahifa/swf/Scripts/expressInstall.swf"> <!-- La balise <object> suivante est destinée aux navigateurs autres qu'IE. Supprimez-la d'IE à l'aide d'IECC. --> <!--[if !IE]>--> <object type="application/x-shockwave-flash" data="wp-content/themes/sahifa/swf/timekeeper.swf" width="<?= $width?>" height="<?= $height?>"> <!--<![endif]--> <param name="quality" value="high"> <param name="wmode" value="<?= $wmode?>"> <param name="swfversion" value="8.0.35.0"> <param name="expressinstall" value="wp-content/themes/sahifa/swf/Scripts/expressInstall.swf"> <param name="FlashVars" value="clickTAG=<?=$flashLink?>" /> <!-- Le navigateur affichera le contenu alternatif suivant pour les utilisateurs d'un lecteur Flash de version 6.0 ou de versions plus anciennes. --> <div id="timekeeper"> <a href="<?= $link; ?>" target="_blank" class="link"></a> <img src="template/images/handH.png" class="hand" id="handH" alt="heure"/> <img src="template/images/handM.png" class="hand" id="handM" alt="minute"/> <img src="template/images/handS.png" class="hand" id="handS" alt="seconde"/> </div> <!--[if !IE]>--> </object> <!--<![endif]--> </object>Do you see anything wrong? How can I make this work in my page? I hope you can help me. Thanks. Regards |