Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

thetanooki on "Can you move the default position of the Featured Image meta box up?"

$
0
0

I'd prefer to do this through the functions.php file, but I don't mind editing the core files if necessary.

Everything I've found on these forums so far involves moving meta boxes from the central area to the right side or vice versa, or moving custom meta boxes up or down. I want to move the actual Featured Image meta box, which seems to default to the bottom of the right side (even below "low" priority custom meta boxes), higher up, above custom meta boxes and perhaps even above the Tags and Categories boxes.

I want to change the default position via code, to help out my writers who always forget to set it since the Featured Image meta box is often below the fold.

Is this doable and I'm just missing something obvious?


William Hagan on "Plugins - Alt API"

$
0
0

Downloads count are no longer displayed in the Wordpress Updates > Plugins > View Version XXXXX details modal.
Is "downloaded" still the parameter used to view this information.

There are no changes to the plugin.
Here's a screenshot of the plugin details as of 20150528:

JukeBoxWhiz on "what's wrong with this php mysql code?"

$
0
0

Trying to learn how retrieve data from a database for display on a wordpress page.

I'm using the sakila database.

I'm using this to display names:

global $wpdb;  $customers = $wpdb->get_results("SELECT first_name FROM sakila.actor;");
while($row[] = mysql_fetch_array( $customers )){
   echo $row[first_name];
}

Here is the error I get:

Warning: mysql_fetch_array() expects parameter 1 to be resource, array given in C:\xampp\htdocs\wordpress\wp-content\themes\twentyfifteen\db-exp.php on line 28

Isn't $customers an array?

Before I tried this code I was using this:

<?php global $wpdb; $customers = $wpdb->get_results("SELECT first_name FROM sakila.actor;"); print_r($customers); ?>

And it printed out the entire array of first names, but included meta data like Array[0]Penelope Array[1]Arnold... all the way through to the 200th item.

So, I figure there is an array within the variable $customers. So why isn't that a resource?

Day Blakely Donaldson on "How to display both categories and tags in a the default archive?"

$
0
0

For example, when someone clicks on the link for "Biology" I would like all posts to display which are either tagged "biology" or checked for the category "Biology."

Can I add something to my archive.php for this?

Thanks, JM

mstdmstd on "Working with global options off ?"

$
0
0

Hi all,
Using WP 4.2 project I see in code in many places global definition of $wpdb var like:
global $wpdb;

And wp-load.php file must be included for this.
But, seems, this needs global options be on in php.ini?
If there is way not to depend on configuration settings in wp project?

Thanks!

syntacular on "Open the attachment details modal"

$
0
0

Yesterday, I posted this topic on the WordPress development stack exchange, but unfortunately no one replied. I thought I'd try here before giving up.

WordPress opens an attachment details modal window when an image is selected in the media library. Is there a way that I can open this modal on a different admin page if I know the attachment's ID? Specifically, can I click a button and have the modal window open?

phoenix696 on "Check for cookie and then redirect/show popup/similar?"

$
0
0

I'm trying to figure out how to

- check for presence of *specific* user specified cookie
- do action (I.e. popup/redirect/etc.) based on cookie presence.

Anyone have any advice on how to do this? I'm using evolve theme as base to work from.

maurice_jager on "Need help converting this function"

$
0
0

Hi,

I've been staring at this function for the better part of the evening and I'm stuck.
I want this function to generate all attached images to a post:

function sc_postimage($atts) {
  extract(shortcode_atts(array(
    "size" => 'large',
    "float" => 'none'
  ), $atts));
  $images =& get_children( 'post_type=attachment&post_mime_type=image&posts_per_page=-1&post_parent=' . get_the_id() );
  foreach( $images as $imageID => $imagePost )
  $fullimage = wp_get_attachment_url($imageID, $size, false);

  return '<div id="gallery"><img data-src="'.$fullimage.'" /></div>';
}
add_shortcode("postimage", "sc_postimage");

The format I need is <img data-src="IMAGE_URL" />

Thank you very much for your help!


KyleWLawrence on "Menu for Showing the Children of 2nd Level Menu Items on 2nd & 3rd Level Pages"

$
0
0

The title may be confusing, but please follow along.

I have a 3-tier menu. There are the parents (1st tier), and some have children (2nd tier), and some of those children have children (3rd tier). I am trying to put together a Walker menu or some menu function so that the following works:

- The menu only displays the 3rd tier
- The menu displays all children of the 2nd tier when the user is on the 2nd or 3rd tier page. For instance, look at the example menu in the image:
Image

In this example, the menu would only ever display "Leadership, Employees, U.S. and Hours" (3rd tiers). The only items that would ever be displayed together are "Leadership and Employees", and each of those would display when the user is either on "Company, Leadership, or Employees".

Does that make sense? Is that possible?

jonathanhooverks on "RSS Delete Elements By Class"

$
0
0

I want to use RSS from wordpress to drive my MailChimp campaigns, but I have several elements on the page that I don't want in my rss (like a gravity form, an image or two that doesn't apply to my email viewers, etc.).

I can use CSS on the mail chimp side to {display:none} the elements with the .hidefromrss class, but because Gmail won't tolerate the display css property, I'm out of luck.

I'd like to obliterate every item with class .hidefromrss from my rss feeds. I don't know which is the best way to go here... should I try to use a php reg_replace statement? Or should I try to use a javascript call using the DOM? Would it be better to use jquery? If so to any of these, could you give an example of how this would be done? I'm open to any potential solution. I thought this would be an easy thing to do. Man, was I ever wrong : )

goresponsive on "how to use is_admin in wp-config.php"

$
0
0

I am trying to choose different databases for admin and user to decrease the load on database.
in wp-config.php when i am trying to use the code
if(is_admin())
{
define('DB_NAME', 'wp_db');
}

I am getting an error of
Fatal error: Call to undefined function is_admin() in D:\xampp\htdocs\wordpress\wp-config.php on line 24

How to use is_admin() function in the wp-config.php file?

can someone please help.

misharnet on "Add option to widget to switch styles?"

$
0
0

I want to create a widget plugin in which you can show social profiles icons. How can I add option, so you can choose different styles of icons.
I hope you understand what i mean?! Drop down menu where you can choose: round icons or square or ribbon ... This is for my own learning purposes.
Thanks in advance.

hughbalboa on "External Mysql Security"

$
0
0

Hi Good day,
i am using wordpress for making a proccess with external DB, (wpdb)
on the pages i am assigning templates for each process, my Quieston is ,
wordpress is safe in those mysql pages with templates? i mean with anti codeinjectors, scriptinjectors, or theirs a way to make it with API content

JukeBoxWhiz on "code in functions.php of child theme causing problems"

$
0
0

I'm working off of a local install. Just experimenting and going by this tutorial:

http://www.makeuseof.com/tag/tutorial-ajax-wordpress/

This is about using AJAX to create a form for database entries. The author wants you to add the following code to your functions.php:

<? php

    wp_enqueue_script('jquery');
    function newTitle(){
	global $wpdb;    $title = $_POST['title'];
		         $year = $_POST['year'];
		         $genre = $_POST['genre'];
 			 $link = $_POST['link'];
		         $decade = $_POST['decade'];
	if($wpdb->insert('films.titles',array(  'title'=>$title,  'year'=>$year,  'genre'=>$genre,  'link'=>$link, 'decade'=>$decade  ))===FALSE){
		echo "Error";
		}  else {
		echo "Title '".$title. "' successfully added, row ID is ".$wpdb->insert_id;
		}  die();
	}

		add_action('wp_ajax_newTitle', 'newTitle');
		add_action('wp_ajax_nopriv_newTitle', 'newTitle'); // not really needed

I changed the names of the variables and names for the forms to accord with the database I'm using as an example.

But, when this code is saved two things happen:

1 - some of the code prints out at the top of the wordpress admin screen. Doesn't matter what section of the admin I'm looking at, the code will appear at the top of the screen. It starts with all the code from just after the if($wpbd-> and prints out everything after. So, the printed code is:

"insert('films.titles',array( 'title'=>$title, 'year'=>$year, 'genre'=>$genre, 'link'=>$link, 'decade'=>$decade ))===FALSE){ echo "Error"; } else { echo "Title '".$title. "' successfully added, row ID is ".$wpdb->insert_id; } die(); } add_action('wp_ajax_newTitle', 'newTitle'); add_action('wp_ajax_nopriv_newTitle', 'newTitle'); // not really needed"

I'm not backticking it because that's the way it appears on the screen.

2 - When I view the site there is gray space created below the header. It's about the size of the header and separates the header from the side column. (this is the twentyfourteen theme). If I delete the code from the functions.php everything goes back to normal. This is the only code in the functions.php for the file in the child theme.

****EDIT****

I tried the bit about adding the end bracket for php the '?>' and making sure there was no whitespace afterwards. That's not the problem.

darktranquilitynyc on "Most recent posts using get_posts()"

$
0
0

i got this from another thread, as the OP was trying to do what I'm trying to do.
I want to make the most recent blog posts come onto a static home page. I have a seperate link to the blog as a whole, but for this particular site, I don't want the blog to be the main page, only the most recent posts.
The code I got is

<?php
global $post;
$myposts = get_posts('numberposts=5 & category=1');
foreach($myposts as $post) :
?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php endforeach; ?>

I put this in the index.php file within the content div.
My theme is 2012 in case it matters.

When I reload the page, none of the posts show up (not the latest ones.).
Thank you


web-girl on "Help with MyPosts If/Else Statement"

$
0
0

Hello,

I am looking for some help modifying this PHP statement. It is used for a slider that shows posts that are tagged "Featured" in my index.php file. Right now, the code looks at whether there are any posts in that category, and if there aren't, it hides the slider. If there are, it shows the slider.

I'd also like to add another condition to this so that if there is only one post, it does something else.

So, end goal is that it: 1) checks for zero posts in the category, and if so outputs nothing 2) checks for only one post in the category, and if so outputs some code 3) checks for more than one post in the category, and outputs another other code.

Any help would be greatly appreciated!

<?php
$myposts = get_posts('posts_per_page=-1&category=24');
if($myposts):
foreach($myposts as $post) :
  setup_postdata($post); ?>
			<?php include (TEMPLATEPATH . '/featured-posts.php'); ?>

<?php endforeach;
else: ?>
<?php endif; ?>

diveman1 on "How to implement a URL API in Wordpress"

$
0
0

Dear Sir/Madam, I'm currently working on a wordpress multi-site where the online ordering system (e-commerce) is a separate website and database. The goal is to get data from the online ordering system to display on the Wordpress multi-sites. The online ordering system has an API that is a URL. As an example:

URL for account holder registration:
http://domain/clothing/accountHolderRegistration.html?cloId=123

URL for the services : http://104.224.181.39:8181/cxs/api/apiService

Headers
authorizationtoken : 2bc20e778efb916a782282236ae27983

Service for fetching the details of individual clothing item:
Input Parameters
consumerName : clomicrosite
data : {"clothingId " : "1"}
serviceName : getClothingDetails
Output
{
"success" : true,
"clothing":{
"clothingDisplayName" : "clothing 1",
"clothingSize" : "Large",
"clothingColor" : "Red",
"clothingPrice" : "$25.00"
"clothingPhoto" : " this will be a large base 64 string",
"testimonials" : [
{"whoSaid" : "xyz",
"whatSaid" : "This is Good"
},
{"whoSaid" : "abc",
"whatSaid" : "This is Bad"
},
{"whoSaid" : "xyz",
"whatSaid" : "This is Average"
}
]
}
}

I know this is probably a dumb question but I'm trying to figure out how to now display this information on a Wordpress page. I'm not sure how to call the API and provide the authentication token, and then parse and display the clothing data. Can anyone help? Any help is very much appreciated. Thanks in advance.

affanjau on "Use Walker or get_comment."

$
0
0

I have recently came across Wordpress Walker, while working on displaying comment. While Comment can be displayed using get_comment(), i just wanted to know, which option would be better, to use Walker or get_comment().

jeriksson on "Slow Query from: edit-form-advanced.php can i remove it?"

$
0
0

Hello,

I have a site that starts to have issues on the editing admin interface, i used query monitor and found a query that was rather slow:

SELECT meta_key
FROM dbwp_postmeta
GROUP BY meta_key
HAVING meta_key NOT LIKE '\\_%'
ORDER BY meta_key
LIMIT 30

I've googled around and found a lot of people who have issues with this query but no real solution. My question is, is this query necessary? To my knowledge this site isn't using any custom fields that i know off, what would happen if i removed this query from running on the edit page?

sescpapa on "random post ceases to be random at subsequent refresh"

$
0
0
<?php
$args = array( 'posts_per_page' => 1, 'orderby' => 'rand' );
$rand_posts = get_posts( $args );
foreach ( $rand_posts as $post ) :
setup_postdata( $post ); ?>
<?php the_content(); ?>

Wrote this a couple of months ago, in line with some advice I got from documentation&forums, with the intention to display the content of a random post - and it worked.
The thing is though I am now noticing that the "randomness" only applies to the first time I visit my site - not at subsequent refresh.
That is, no matter how many times I refresh my site, I get the same post, that was originally loaded as random.
Obviously, my question is: Why is this happening?
I'm thankful for all the help I can get.

Viewing all 8245 articles
Browse latest View live




Latest Images