I have a wordpress theme which does not grant access to .html files, its loads the html which I need to style like this:
<!--Header Start-->
<?php get_template_part( 'templates/headers/xv', 'nav' ); ?>
<?php get_template_part( 'templates/headers/search', 'bar' ); ?>
I need to make changes in the header, there is a link which simpy has to be changed
<a class="navbar-brand" href="http://THISMUSTBECHNAGED.eu/">
<img src="Image.png" >
</a>
I have checked all possibilites which the template itself offers and didnt found a possibility to change the link destination, also the Text Editor in Wordpress grants access to all the .php files, but none of them is working with the navbar, it loads it from get_template_part as I show in the first code sample.
Thats what I tried witch JS, but didnt worked:
jQuery(document).ready(function(){
document.getElementByClassName("navbar-brand").href="NEWLINK";
});
jQuery(document).ready(function(){
$(".navbar-brand").attr("href", "NEWLINK")
});
jQuery(document).ready(function(){
var x = document.getElementsByClassName("navbar-brand");
x[0].href = "NEWLINK";
});
Is there a way to select this href with css und change the link this way?
Thats the theme: http://xvelopers.com/wp/themes/voltov/
The Full header.php:
<?php?>
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-- >
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html <?php language_attributes(); ?> class="no-js">
<!--<![endif]-->
<?php global $xv_data; //fetch options stored in $xv_data ?>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta name="viewport" content="minimum-scale=1.0, width=device-width, maximum-scale=1, user-scalable=no" />
<link rel="shortcut icon" href="<?php if(!empty($xv_data['fav_icon']
['url'])){ echo esc_url($xv_data['fav_icon']['url']);}else{ echo
esc_url(get_template_directory_uri() . '/assets/img/favicon.png'); }?>" type="image/x-icon" />
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?> data-spy="scroll" data-target=".pages-wrapper">
<div class="wrapAllContent">
<!--Header Start-->
<?php get_template_part( 'templates/headers/xv', 'nav' ); ?>
<?php get_template_part( 'templates/headers/search', 'bar' ); ?>
EDIT:
Thats the .php which is used to create the navbar element and the homelink is created via boolean = true, setting it to false doesnt make my JS work. I have no clue how to customize this:
<?php
/**
* xvelopers's Theme Core Functions
*
* Eventually, some of the functionality here could be replaced by core features
*
* #package voltov
*/
/**
* Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
*
* #param array $args Configuration arguments.
* #return array
*/
function voltov_page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
add_filter( 'wp_page_menu_args', 'voltov_page_menu_args' );
/**
* Adds custom classes to the array of body classes.
*
* #param array $classes Classes for the body element.
* #return array
*/
function voltov_body_classes( $classes ) {
// Adds a class of group-blog to blogs with more than 1 published author.
// Adds a class of group-blog to blogs with more than 1 published author.
if ( is_multi_author() )
$classes[] = 'group-blog';
if(is_archive() || is_search())
$classes[] = 'sidebar-disabled';
return $classes;
}
add_filter( 'body_class', 'voltov_body_classes' );
//add active class in selected page
add_filter('nav_menu_css_class' , 'voltov_nav_class' , 10 , 2);
function voltov_nav_class($classes, $item){
if( in_array('current-menu-item', $classes) ){
$classes[] = 'active '; // your new class
}
return $classes;
}
/*
Custom Excerpt
*/
function voltov_get_excerpt($count,$read=true){
global $post;
$permalink = get_permalink($post->ID);
$excerpt = get_the_content();
$excerpt = strip_tags($excerpt);
$excerpt = substr($excerpt, 0, $count);
$excerpt = substr($excerpt, 0, strripos($excerpt, " "));
if($read != false){
$excerpt = $excerpt.'<a class="readmore" href="'.$permalink.'"> '. __('Weiterlesen','voltov').'</a>';
}
echo wp_kses($excerpt,'a');
}
/*
* Pagination code
*/
function voltov_get_pagination($pages = '', $range = 4)
{
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}
if(1 != $pages)
{
echo "<div class=\"pagination\">";
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>« First</a>";
previous_posts_link('<i class="icon-chevron-left pagination-icon"></i>');
//echo "<a href='".get_pagenum_link($paged - 1)."'><i class='icon-chevron-left pagination-icon'></i></a>";
for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{
echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"".$i."";
}
}
//echo "<i class='icon-chevron-right pagination-icon'></i>";
next_posts_link('<i class="icon-chevron-right pagination-icon"></i>','');
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last »</a>";
echo "</div>\n";
}
}
/**
* Thumbnail Resizer & Image functions
*
*/
function xv_get_resizer($image_url='',$width='',$height='',$crop='c'){
$image ="http://placehold.it/{$width}x{$height}";
if (!empty($image_url)) {
$image = theme_thumb($image_url, $width, $height,$crop);
}
return esc_url($image);
}
function xv_get_thumbnail($width,$height){
global $post;
$thumb ="http://placehold.it/{$width}x{$height}";
if ( has_post_thumbnail() ) {
$image_src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), "full");
$image_url = $image_src[0];
$thumb = theme_thumb($image_url, $width, $height, 'c');
}
return esc_url($thumb);
}
function xv_get_thumbnail_url($size = 'full'){
global $post;
if ( has_post_thumbnail() ) {
$image_src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), $size);
$image_url = $image_src[0];
}else{
$image_url = 'No Image';
}
return esc_url($image_url);
}
function xv_get_image_url($post_id){
$image_src = wp_get_attachment_image_src( $post_id, "full");
$image_url = $image_src[0];
return esc_url($image_url);
}
/**
* Checks if a post thumbnails is already defined.
*
*/
function voltov_is_post_thumbnail_set()
{
global $post;
if (get_the_post_thumbnail()) {
return true;
} else {
return false;
}
}
function voltov_autoset_featured_img()
{
global $post;
$post_thumbnail = voltov_is_post_thumbnail_set();
if ($post_thumbnail == true) {
return get_the_post_thumbnail();
}
$image_args = array(
'post_type' => 'attachment',
'numberposts' => 1,
'post_mime_type' => 'image',
'post_parent' => $post->ID,
'order' => 'desc'
);
$attached_images = get_children($image_args, ARRAY_A);
$first_image = reset($attached_images);
if (!$first_image) {
return false;
}
return get_the_post_thumbnail($post->ID, $first_image['ID']);
}
function xv_get_sidebars_array() {
global $xv_data;
$sidebars = array();
$sidebars['default'] = __('Default', 'framework');
if (isset($xv_data) && isset($xv_data['custom-sidebars']) && is_array($xv_data['custom-sidebars'])) {
foreach ($xv_data['custom-sidebars'] as $sidebar) {
$sidebars[sanitize_title ( $sidebar )] = $sidebar;
}
}
return $sidebars;
}
function xv_page_sidebar_id($position, $default = 'default')
{
if (function_exists('get_field')) {
$sidebar = get_field($position);
} else {
$sidebar = '';
}
if (empty($sidebar))
{
$sidebar = $default;
}
return $sidebar;
}
function xv_get_post_type_categories($post_type='')
{
if(!empty($post_type)){
$terms = get_terms($post_type);
}else{
$args = array(
'orderby' => 'name',
'parent' => 0
);
$terms = get_categories( $args );
}
$categories = array();
$categories[__('All', 'framework')] = '';
foreach ( $terms as $term ) {
$categories[] = $term->slug;
}
return $categories;
}
function xv_get_posts_list($post_type='')
{
global $post;
$args = array( 'numberposts' => -1,'post_type'=>$post_type);
$posts = get_posts($args);
$posts_list = array();
foreach( $posts as $post ) : setup_postdata($post);
$posts_list[] = get_the_title( $post_id ) ;
// );
endforeach;
return $posts_list;
}
/**
* Include Menu Walker Class
*
*/
function xv_set_post_views($postID) {
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
//To keep the count accurate, lets get rid of prefetching
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
add_filter('mce_buttons','wysiwyg_editor');
function wysiwyg_editor($mce_buttons) {
$pos = array_search('wp_more',$mce_buttons,true);
if ($pos !== false) {
$tmp_buttons = array_slice($mce_buttons, 0, $pos+1);
$tmp_buttons[] = 'wp_page';
$mce_buttons = array_merge($tmp_buttons, array_slice($mce_buttons, $pos+1));
}
return $mce_buttons;
}
Thanks!
EDIT 2:
Okay, I have tried simply to upload an other Logo for the header, it automaticaly creates a homelink to the site itself and disables access to change the link. So I guess its simply not possible for this theme.
I was working on my website and noticed that the <center> tab was not working correctly. I have an element wrapped in a <div id="main'> and a <center> tab and all of the rows of text don't line up correctly.
<?php
require('/inc.all.php');
$_SESSION['lastUrl'] = $_SERVER['REQUEST_URI'];
// Get total count of rows
$sql = "SELECT COUNT(username) FROM user_profile WHERE hideFromUserCount='0'";
$query = $db->query($sql);
$row = $query->fetch_row();
// Total row count
$rows = $row[0];
//Number of results per page
//if($rows < 10){
// $page_rows = $rows -1;
//}else{
$page_rows = 10;
//}
//Tells us number of last page
$last = ceil($rows/$page_rows);
if($last < 1)
$last = 1;
//Establish $pagenum variable
$pagenum = 1;
if(isset($_GET['pg']))
$pagenum = preg_replace('#[^0-9]#', '', $_GET['pg']);
else
$pagenum = 1;
//Makes sure pagenumber isnt below 1 or more than $last
if($pagenum < 1)
$pagenum = 1;
else if($pagenum > $last)
$pagenum = $last;
//Sets range of rows for chosen $pagenum
$limit = 'LIMIT '.($pagenum-1) * $page_rows.','.$page_rows;
$sql = "SELECT username FROM user_profile WHERE hideFromUserCount='0' ORDER BY username ASC $limit";
$query = $db->query($sql);
$show_start = $pagenum * $page_rows;
$show_end = (($pagenum * $page_rows) + $page_rows)-1;
$textline1 = "Total Profiles: <b>$rows</b>";
$textline2 = "Page <b>$pagenum</b> of <b>$last</b>";
$paginationCtrls = '';
if($pagenum > 1){
$previous = $pagenum-1;
$paginationCtrls .= "<li>Prev</li>";
for($i = $pagenum-4; $i < $pagenum; $i++){
if($i > 0){
$paginationCtrls .= "<li>$i</li>";
}
}
}else{
$previous = $pagenum-1;
$paginationCtrls .= "<li class='disabled'>Prev</li>";
}
$paginationCtrls .= "<li class='disabled'>$pagenum</li>";
for($i = $pagenum+1; $i<=$last; $i++){
$paginationCtrls .= "<li>$i</li>";
if($i >= $pagenum+4){
break;
}
}
if($pagenum != $last){
$next = $pagenum +1;
$paginationCtrls .= "<li>Next</li>";
}else{
$next = $pagenum +1;
$paginationCtrls .="<li class=\"disabled\">Next</li>";
}
$usernames = "";
while($row = $query->fetch_assoc()){
$username = $row['username'];
$usernames .="<br>$username<br>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Minecraft Profiles | Profiles</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="style/css/style_viewProfile.css">
<link href="style/css/bootstrap.css" rel="stylesheet" type="text/css">
</head>
<body>
<!--<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<a class="brand" href="index">Minecraft Profiles</a>
<ul class="nav">
<li>Home</li>
<li class="active">Profiles</li>
<li>Find User</li>
<li>Create a Profile</li>
<li>User Dashboard</li>
<?php
if(isset($_SESSION['username']) && isset($_SESSION['password'])){
echo "<li> Welcome Back, ".$_SESSION['username']."! Click to log out</li>";
}else{
echo "<li>Login</li>";
}
?>
</ul>
</div>
</div>-->
<br />
<br />
<div id="header">
<h1>Profiles</h1>
</div>
</div>
<div id="content">
<div id="sidebar">
<strong>Featured Profiles</strong>
<br />
<?php
$sql = "SELECT username FROM user_profile WHERE featured = 1";
$query = $db->query($sql);
while($row = $query->fetch_assoc()){
$username = $row['username'];
echo "$username";
echo "<br />";
}
?>
</div>
<div id="main">
<center>
<?php echo $textline1;?><br />
<?php echo $textline2; ?><br />
<?php if(isset($usernames)) {echo $usernames; }?><br />
<div class="pagination"><ul><?php echo $paginationCtrls; ?></ul></div></center>
</div>
<div class="clear">
<?php
$sql="SELECT * FROM user_profile WHERE hideFromUserCount = 0";
$query=$db->query($sql);
echo "<div class=\"clear\"><br /><center>Minecraft Profiles is proud to have ".$query->num_rows." unique profile(s) registered in our databases!</center></div>";
?>
</div>
</div>
</body>
</html>
$textline1 and $textline2 just show some text on the screen. The end result looks like This
Have you tried removing the <center> altogether and styling the div?
<div id="main" style="text-align: center;">
Also - you'll need #main to have a width so CSS knows how wide to centre the text across
Hi I have a table which I am trying to update with a call to a MySQL database in a separate php page. This separate page loops through a result set and builds the table through a series of echos. In the main page I am trying to insert that echoed content into a div.
This is all kicked off by the user selecting an option from a drop down box.
This is the separate php page. (It works fine when i manually type in the GET parameters, it is the link between the two pages which doesn't seem to work)
tableGetter.php
<?PHP
$user_name = "rocketeermus_pr";
$password = "zuluhead2";
$database = "rocketeermus_pr";
$server = "pdb1.awardspace.com";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
echo "Bonjour";
if (isset($_GET['composer'])){
echo "Helloooo";
if ($db_found) {
echo "SELECT * FROM catalogue WHERE Composer = '".mysql_escape_string($_GET['composer'])."';";
$SQL = "SELECT * FROM catalogue WHERE Composer = '".mysql_escape_string($_GET['composer'])."';";
$result = mysql_query($SQL);
setlocale(LC_MONETARY,"en_GB");
echo "<table class=\"sortable\" id=\"moder\" width=\"800\">";
echo "<th>TITLE</th><th>COMPOSER</th><th>VOICING</th><th>PRICE</th><th></th></tr>";
while ( $db_field = mysql_fetch_assoc($result) ) {
echo "Hi.";
echo "<tr><td>{$db_field['Title']}</td><td>{$db_field['Composer']}</td><td>{$db_field['Voicing']}</td><td>";
echo money_format("%n", $db_field['Price']);
echo "</td><td> <div class=\"product\"> <input value=\"{$db_field['Title']}\" class=\"product-title\" type=\"hidden\"> <input value=\"0.5\" class=\"product-weight\" type=\"hidden\"> <input value=\"{$db_field['NoVox']}\" class=\"googlecart-quantity\" type=\"hidden\"> <input value=\"{$db_field['Price']}\" class=\"product-price\" type=\"hidden\"> <div title=\"Add to cart\" role=\"button\" tabindex=\"0\" class=\"googlecart-add-button\"> </div> </div> </td></tr>";
}
echo "</table>";
mysql_close($db_handle);
} else {
print "Database NOT Found ";
mysql_close($db_handle);
}
}
?>
And here is the important stuff from the main page:
Javascript:
function getdata()
{
var req = getXMLHTTP();
if (req)
{
//function to be called when state is changed
var queryString1 = "";
req.onreadystatechange = function()
{
//when state is completed i.e 4
if (req.readyState == 4)
{
var ajaxSearchResults1 = document.getElementById("table");
ajaxSearchResults1.innerHTML = req.responseText;
// only if http status is "OK"
if (req.status == 200)
{
var new1 = document.getElementById('composer').value;
queryString1 = "?composer=" + encodeURIComponent(new1);
console.log (queryString1);
}
else
{
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", "tableGetter.php" + queryString1, true);
req.send();
}
}
function getXMLHTTP() {
var xmlhttp;
if(window.XMLHttpRequest){ //For Firefox, Mozilla, Opera, and Safari
xmlhttp = new XMLHttpRequest();
}
else if (window.ActiveXObject){ //For ie
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
if (!xmlhttp){
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}
}
return xmlhttp;
}
html:
<div id="menus">
<table>
<tr>
<td><form action=""">
<select name="composer" id ="composer" onchange="getdata();">
<?php
$user_name = "***";
$password = "****";
$database = "****";
$server = "****.com";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
if ($db_found) {
$SQL = "SELECT DISTINCT Composer FROM catalogue ORDER BY Composer";
$result = mysql_query($SQL);
setlocale(LC_MONETARY,"en_GB");
while ( $db_field = mysql_fetch_assoc($result) ) {
?>
<option id="composer" onchange="getdata();" value="<?php echo $db_field['Composer'];?>">
<?php
echo $db_field['Composer'];
?>
</option>
<?php
}
}
?>
</select>
</form></td>
</tr>
</table>
</div>
<div id="table">
<?php include("tableGetter.php"); ?>
</div>
The html on the main page works fine, the drop down menu fills up nicely with all the distinct composer names in the database. When an option in the menu is selected the only thing echoed in the "table" div is "Bonjour". It's not getting further than if (isset($_GET['composer'])) in the tableGetter.php page. I'm printing out the queryString1 variable (The get parameters) which is requested in the getData() function and it reports: ?composer=Animuccia%2C%20Paulo which works perfectly when loading the page manually. It just won't work dynamically!
Anybody know what's going on here?
You aren't setting queryString1 before sending the AJAX request. Try this rewrite of getdata().
function getdata()
{
var req = getXMLHTTP();
if (req)
{
//function to be called when state is changed
req.onreadystatechange = function()
{
//when state is completed i.e 4
if (req.readyState == 4)
{
// only if http status is "OK"
if (req.status == 200)
{
var ajaxSearchResults1 = document.getElementById("table");
ajaxSearchResults1.innerHTML = req.responseText;
}
else
{
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
var new1 = document.getElementById('composer').value;
var queryString1 = "?composer=" + encodeURIComponent(new1);
req.open("GET", "tableGetter.php" + queryString1, true);
req.send();
}
}
I have a rank to determine the user level, (e.g. rank 1 = registered, rank3 = admin), and everything works fine in my script below.
<?php
session_start();
require('../../config.php');
$qry=("SELECT `rank`, `uname` FROM users");
$result=mysql_query($qry);
$row = mysql_fetch_assoc($result);
$rank = $row['rank'];
$user = $_SESSION['user'];
$logged = $_SESSION['loggedin'];
if ($logged == true) {
if ($rank >= 3) {
echo "Succesful, $user.<br />
<form method='POST' action='delete.php'>
<select><option>Please select</option>";
while ($row = mysql_fetch_assoc($result)) {
$users = $row['uname'];
$lol = ucwords($users);
}
echo "<option>$lol</option>";
echo "</select>
</form>";
} else {
echo "Your not an admin.";
}
} else {
echo "Please login.";
}
?>
But, once I add a new user to the database, (2 rows in database), it says "Your not an admin".
Please help. Thank you.
Shouldn't add the where condition to specify which user? Like use the userid?
$qry=("SELECT `rank`, `uname` FROM users WHERE uid = $uid");
I basically need to have take some videos information out of a database with a while loop and put them into a div. The only issue is that I need to put only 6 at a time in between a and tag and have it go to the next 6 and so forth. Here's my code:
$count = 0;
$sql = "SELECT * FROM videos ORDER BY id DESC";
$result_set = $database->query($sql);
while($videos = $database->fetch_array($result_set)) {
$count++;
// i know this is horribly wrong...
if($count == 0 || (($count % 6)+1 == 1)) {
echo '<div>';
}
// i need 6 videos to go in between the <div> and </div> tags then go on to another 6
echo "{$videos['title']}";
if($count == 0 || (($count % 6)+1 == 1)) {
echo '<div>';
}
}
This is an efficent way to do what you want:
$resultPerPage = 6;
$count = 0;
$sql = "SELECT * FROM videos ORDER BY id DESC";
$result_set = $database->query($sql);
$noPage = 1;
echo '<div id="page_1" class="pages">';
while($videos = $database->fetch_array($result_set)) {
$count++;
echo "{$videos['title']}";
if($count == $resultPerPage) {
echo '</div><div id="page_' . $noPage++ . '" class="pages">';
$count=0;
}
}
echo '</div>';